Ad space (banner)
AD

Got the fundamentals? A structured Docker course is a fast way to level up.

Find Docker courses on Udemy

Affiliate link. Costs you nothing extra.

🐳Docker Lessons
Lesson 8 / 45

Running in the Background with docker run -d

When you don't want the container to tie up your terminal, add -d. Short for "detach," it runs the container in the background.

The syntax is docker run -d image. Your prompt comes straight back, and you can carry on working.

Running docker run -d nginx prints only the container's ID and returns immediately, while nginx keeps running in the background.

A common stumble is forgetting a detached container is still running, then wondering later why a port is occupied. Check with docker ps.

In real work, anything long-lived — web servers, databases — is started with -d.

Docker
Try it (type this into the pseudo terminal)
docker run -d nginx

🧑‍💻 You can type this command into the Docker pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)