Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Docker Tutorials: Detached (-d) mode in Docker – Explained

We use Docker detached mode (-d) when we want to connect to the container in an interactive mode or we can say when we just want application to be running inside the container. This means, we can start up the container and could use the console after startup for other commands.

It runs the container in the background of your terminal. It does not receive input or display output.

We can use following commands to runs docker container in detached mode and print “Hello World” every one second:-

docker run —name <contName> -d <imgName> /bin/bash -c “while true; do echo Hello World; sleep1; done” 

If we want to cross check if the container is running, we can use this command

docker ps 

For checking logs of the container, we can use

docker logs -f

If needed to attach the container and interact with it (go inside container), use following:-

docker run -it <imgName> <entryPoint>

If you want to learn Docker from scratch up to certification level you may refer this playlist:-

Mantosh Singh
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x