DiegoMedeiros
DiegoMedeiros

Reputation: 31

Podman container exits immediatly after run

I am running a containter in podman, I used the following containerfile to build the image:

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y apache2
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
CMD ["service", "apache2", "start"]

EXPOSE 8080

After the image is built I run podman run -d -i -t -p 8080:80 myImage, then the container is created and exit immediatly. The container's log show only this: * Starting Apache httpd web server apache2.

If I ommit this line CMD ["service", "apache2", "start"] in the containerfile when I build the image, the container remains runnig OK.

My OS is Windows 10 Pro 21H2 What am i doing wrong?

Upvotes: 0

Views: 115

Answers (1)

Richard Huxton
Richard Huxton

Reputation: 22943

The container command exits, so the container halts. That's the whole point of application containers. What the command did (start Apache) is irrelevant.

If you want something more like a VM or a physical server then you want a system container. Something like incus/lxd/lxc. I don't believe any of those have Windows client apps and VMs packaged up like docker/podman though.

Upvotes: 0

Related Questions