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?
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.
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.
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.
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.
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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With