Xar
Xar

Reputation: 7940

Dockerized nginx shuts down after a few seconds

I'm working with Ubuntu 18 and I´m trying to run a dockerized nginx with a shared file between the host machine and the container: /home/ric/wrkspc/djangodocker/djangodocker/nginx.conf

I do so by running the following command, after which I'm prompted with container's ID:

$ sudo docker container run -v /home/ric/wrkspc/djangodocker/djangodocker/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx
facc4d32db31de85d6f360e581bc7d36f257ff66953814e985ce6bdf708c3ad0

Now, if I try to list all the running containers, the nginx one doesn't appear listed:

(env) ric@x:~/wrkspc/djangodocker/djangodocker$ sudo docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
36090ff0759c        mysql               "docker-entrypoint.s…"   3 days ago          Up 3 days           0.0.0.0:3306->3306/tcp, 33060/tcp   boring_panini

Sometimes, if I run the docker ls command fast enough, I can see the nginx container listed for just a few seconds and then it disappears.

Why is the nginx container not being listed?

Upvotes: 0

Views: 1424

Answers (1)

Shiju
Shiju

Reputation: 436

I think container immediately exits after started.

can you troubleshoot by looking into docker logs using the command docker logs containerID

Also, you can try running the container interactively to identify the error without using -d option

Upvotes: 1

Related Questions