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.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github