Menu
Coddy logo textTech

Detached Containers

Part of the Introduction to Docker section of Coddy's Terminal journey — lesson 13 of 40.

Some images run long-lived services (a web server, a database) rather than a quick command. You start those in the background with the -d (detached) flag:

docker run -d --name web nginx

Instead of streaming the container's output, Docker prints the container's ID and returns control to you straight away. The container keeps running in the background.

To see all the containers that are currently running, use docker ps:

docker ps

Each row shows the container ID, the image, the command, the status, and the name.

challenge icon

Challenge

Easy

Start a detached nginx container named site, then run docker ps to confirm it is running.

Cheat sheet

Run a container in the background with -d (detached) and assign it a name with --name:

docker run -d --name web nginx

List all running containers:

docker ps

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Introduction to Docker