In docker, you can use the ps command to view how many containers there are. This command is used to list the containers. When the parameter is set to "-a", you can display all containers including those that are not running. 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 the output.
-q: Silent mode, only the container number is displayed.
-s: Display the total file size.
The example is as follows:
List 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: 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
removing
paused
exited (stop)
dead (death)
PORTS: The port of the container Information and connection type used (tcp\udp).
NAMES: Automatically assigned container name.
Recommended learning: "docker video tutorial"
The above is the detailed content of How to check how many containers there are in docker. For more information, please follow other related articles on the PHP Chinese website!