Vitaliy photo

by Vitaliy M.

Conten Manager


How to Keep Docker Containers Running

Docker Containers Running

Docker containers, when run in detached mode (the most common -d option), are designed to shut down immediately after the initial entrypoint command (program that should be run when container is built from image) is no longer running in the foreground. This can cause problems because often servers or services running in Docker containers are run in the background, causing your container to shut down before you want it to.

If you would like to keep your container running in detached mode, you need to run something in the foreground. An easy way to do this is to tail the /dev/null device as the CMD or ENTRYPOINT command of your Docker image.

CMD tail -f /dev/null

This command could also run as the last step in a custom script used with CMD or ENTRYPOINT.

Sample Dockerfile

FROM ubuntu:16.04

# other commands

CMD tail -f /dev/null

Related Articles

lead generation

Top Lead Generation Companies on the Market

Top Lead Generation Companies on the Market - What lead generation services are you looking for? Find out everything about unique solutions from the leading companies in the industry in this article. Best Lead Generation Companies and Their Services ...

Financial App

Criteria for Choosing Financial App Development Companies

The cost of a financial application depends on many things including the reputation and rates of the developer, the number of features and experts in the team, and the overall complexity of the project. ...


7 Ways to Delight Your Customers and Help Increase Company Revenue

Today's customers require exceptional service. What modern business methods do you use to provide delightful customer service? If you're reading this article, you, at least, need some more of them, right? We have a few tips you might want to check. So let ...

Improve Your Online Presence!

We exceed your expectations! Create a company profile and get noticed by thousands in no time!

Submit Profile