0
0
Dockerdevops~15 mins

Running containers in detached mode in Docker - Mini Project: Build & Apply

Choose your learning style9 modes available
Running Containers in Detached Mode
📖 Scenario: You are learning how to run Docker containers in the background so they keep running without blocking your terminal. This is useful when you want your container to run continuously while you do other tasks.
🎯 Goal: You will create and run a Docker container in detached mode, so it runs in the background.
📋 What You'll Learn
Create a Docker container using the nginx image
Run the container in detached mode using the -d flag
Name the container mynginx
Verify the container is running in detached mode
💡 Why This Matters
🌍 Real World
Running containers in detached mode is common when deploying web servers or services that need to run continuously without tying up your terminal.
💼 Career
Understanding detached mode is essential for DevOps roles managing containerized applications in production environments.
Progress0 / 4 steps
1
Pull the nginx image
Run the command docker pull nginx to download the nginx image from Docker Hub.
Docker
Need a hint?

Use docker pull nginx to get the image from the internet.

2
Run the nginx container in detached mode
Run the command docker run -d --name mynginx nginx to start the nginx container in detached mode with the name mynginx.
Docker
Need a hint?

Use -d to run detached and --name mynginx to name the container.

3
Check running containers
Run the command docker ps to list all running containers and confirm mynginx is running.
Docker
Need a hint?

Use docker ps to see running containers.

4
Display the container status
Run the command docker ps --filter "name=mynginx" --format "{{.Names}} is {{.Status}}" to show the status of the mynginx container.
Docker
Need a hint?

This command filters containers by name and formats output to show status.