Will the Docker container automatically stop after "docker run -d"?

Better Stack Team
Updated on April 14, 2023

No, the Docker container will not automatically stop after running the docker run -d command. The -d flag tells Docker to run the container in "detached" mode, which means that it will run in the background and not print the container's output to the console. However, the container will continue to run until you explicitly stop it using the docker stop command.

To see a list of all running containers, you can use the docker ps command. This will show you the container ID, name, status, and other information about all running containers on your system.

To stop a container, you can use the docker stop command followed by the container ID or name. For example, if your container's ID is 123abc, you can stop it with the following command:

 
docker stop 123abc

This will send a signal to the container telling it to stop. If the container does not stop gracefully, you can use the docker kill command to forcibly stop it:

 
docker kill 123abc

This will immediately stop the container without giving it a chance to shut down gracefully.

Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →

Reliability is the
ultimate feature

Delightful observability tools that turn your logs & monitoring into a secret weapon for shipping better software faster.

Explore Better Stack