All Articles

How to Keep a Docker Container Running

Docker Daemon

When you run a docker container, you may want to keep it running even if the main process is finished. For example, you may want to keep the container running to check the logs or to debug the container. In this case, you can use the tail -f /dev/null command to keep the container running.

docker run -d [image-name] tail -f /dev/null

Then we could use the docker exec command to enter the container when you need.

docker exec -it [container-id] /bin/bash

Published Feb 13, 2025

Flying code monkey