521 views 26 secs 0 comments

How to Keep Docker Container Running for Debugging

In General
April 18, 2021


This post will look at how to keep a Docker container running for testing, debugging, and troubleshooting purposes.

When you are getting started with Docker, you might have faced the problem of Docker container exiting immediately after starting.

Normally this does not occur if you try to run a official Nginx container.

But if you run a base ubuntu image, the container will exit right after running it.

Here is a screenshot showing both running Nginx container and exited ubuntu container.

docker running min

Here is the reason for it.

  1. To keep the container running, you need a foreground process added to the Docker Entrypoint.
  2. In the official Nginx image, the Nginx foreground process is part of the Dockerfile. See official Nginx Dockerfile.
  3. Whereas, in the base Ubuntu image, there is no Entrypoint for the foreground process. That’s why it gets exited right after you execute the docker run command.

Let see how to add a Entrypoint that keeps the ubuntu image running.

Dockerfile Command to Keep the…



Continue reading on source link

Leave a Reply
You must be logged in to post a comment.