0
0
Dockerdevops~15 mins

Listing containers (docker ps, docker ps -a) - Mini Project: Build & Apply

Choose your learning style9 modes available
Listing Docker Containers with docker ps and docker ps -a
📖 Scenario: You are managing Docker containers on your local machine. You want to see which containers are currently running and also check all containers including those that have stopped.
🎯 Goal: Learn how to list running Docker containers using docker ps and list all containers including stopped ones using docker ps -a.
📋 What You'll Learn
Use the docker ps command to list running containers
Use the docker ps -a command to list all containers including stopped ones
Understand the difference between the two commands
💡 Why This Matters
🌍 Real World
Docker containers are used to run applications in isolated environments. Knowing how to list running and stopped containers helps you manage and troubleshoot your applications.
💼 Career
DevOps engineers and system administrators frequently use these commands to monitor and manage containerized applications in development and production.
Progress0 / 4 steps
1
Create a running Docker container
Run a Docker container in detached mode using the nginx image with the container name webserver. Use the command docker run -d --name webserver nginx.
Docker
Need a hint?

Use docker run with -d to run the container in the background and --name to assign the container a name.

2
List running containers with docker ps
Use the command docker ps to list all currently running containers.
Docker
Need a hint?

The docker ps command shows only containers that are running.

3
Stop the running container
Stop the container named webserver using the command docker stop webserver.
Docker
Need a hint?

Use docker stop followed by the container name to stop it.

4
List all containers including stopped with docker ps -a
Use the command docker ps -a to list all containers including those that are stopped.
Docker
Need a hint?

The -a option with docker ps shows all containers, running or stopped.