Home > Article > Operation and Maintenance > What command does docker use to view running containers?
In docker, you can use the ps command to view running containers. The purpose of this command is to list the containers. When the parameter is set to "-a", all containers including those that are not running can be displayed. The syntax is "docker ps -a".
The operating environment of this tutorial: linux7.3 system, docker-1.13.1 version, Dell G3 computer.
docker ps: List containers
Syntax
docker ps [OPTIONS]
OPTIONS Description:
-a: Display all containers, including those that are not running.
-f: Filter the displayed content based on conditions.
--format: Specify the template file for the return value.
-l: Display recently created containers.
-n: List the recently created n containers.
--no-trunc: Do not truncate output.
-q: Silent mode, only the container number is displayed.
-s: Display the total file size.
Instance
Lists all running container information.
runoob@runoob:~$ docker ps CONTAINER ID IMAGE COMMAND ... PORTS NAMES 09b93464c2f7 nginx:latest "nginx -g 'daemon off" ... 80/tcp, 443/tcp myrunoob 96f7f14e99ab mysql:5.6 "docker-entrypoint.sh" ... 0.0.0.0:3306->3306/tcp mymysql
Output details:
CONTAINER ID: Container ID.
IMAGE: The image used.
COMMAND: The command to run when starting the container.
CREATED: The creation time of the container.
STATUS: Container status.
There are 7 states:
created (created)
restarting (restarting)
running (running)
removing (migrating)
paused (paused)
exited (stopped)
dead (dead)
PORTS: Container port information and used Connection type (tcp\udp).
NAMES: Automatically assigned container names.
List the information of the 5 recently created containers.
runoob@runoob:~$ docker ps -n 5 CONTAINER ID IMAGE COMMAND CREATED 09b93464c2f7 nginx:latest "nginx -g 'daemon off" 2 days ago ... b8573233d675 nginx:latest "/bin/bash" 2 days ago ... b1a0703e41e7 nginx:latest "nginx -g 'daemon off" 2 days ago ... f46fb1dec520 5c6e1090e771 "/bin/sh -c 'set -x \t" 2 days ago ... a63b4a5597de 860c279d2fec "bash" 2 days ago ...
Recommended learning: "docker video tutorial"
The above is the detailed content of What command does docker use to view running containers?. For more information, please follow other related articles on the PHP Chinese website!