Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker container disappears without notice

Tags:

docker

dokku

I host my webapplication is a docker container using Dokku.

Sometimes (maybe every 1-2 days) the docker container just disappears (doesnt show when docker ps) and as a result, my server goes down.

I haven't been able to find the cause.

I am looking for a way to debug this, any ideas?

like image 767
Tarlen Avatar asked Jul 25 '16 08:07

Tarlen


People also ask

Why is my docker container exiting immediately?

Why docker container is exited immediately? You're running a shell in a container, but you haven't assigned a terminal: If you're running a container with a shell (like bash ) as the default command, then the container will exit immediately if you haven't attached an interactive terminal.

Why does my docker container keep stopping?

The main process inside the container has ended successfully: This is the most common reason for a Docker container to stop! When the process running inside your container ends, the container will exit. Here are a couple of examples: You run a container, which runs a shell script to perform some tasks.

How do I stop docker containers from exiting?

According to this answer, adding the -t flag will prevent the container from exiting when running in the background. You can then use docker exec -i -t <image> /bin/bash to get into a shell prompt.

How do I troubleshoot an exited docker container?

As we have said, docker run command launch docker container by reading Dockerfile. Any error in this can exit the container. So, our Support Engineers check the Dockerfile and correct it. For instance, changing the COPY command to AND command can fix this error.


2 Answers

The Docker logs will give you the stdout and stderr for the container. Your application may or may not provide useful information here.

docker logs <containerid_or_name> 

The Docker daemon can manage a long running container for you with a --restart policy.

docker run --restart=always <image>
like image 189
Matt Avatar answered Sep 28 '22 05:09

Matt


Your application server has crashed apparently for whatever reason. you can see why with using docker logs {container_id} . also to prevent your application from going down in the future use --restart=always with your docker run so it will restart automatically on each crash

like image 21
Miad Abrin Avatar answered Sep 28 '22 04:09

Miad Abrin