Listing Docker Containers
Once you have Docker containers running, you'll need to be able to list and manage them. Docker provides several commands to list and inspect containers, allowing you to understand their current state and interact with them.
Listing All Containers
To list all running Docker containers, you can use the docker container ls
command:
docker container ls
This will display a table with information about the running containers, including the container ID, image, command, creation time, status, and ports.
If you want to list all containers, including those that are not running, you can use the -a
or --all
flag:
docker container ls -a
This will show you all the containers that have been created, regardless of their current state.
Listing Container Details
To get more detailed information about a specific container, you can use the docker container inspect
command:
docker container inspect <container_id>
This will output a JSON object containing detailed information about the container, such as its configuration, network settings, and resource usage.
You can also use the docker container stats
command to get real-time performance metrics for one or more containers:
docker container stats <container_id>
This will display a live stream of CPU, memory, network, and disk I/O usage for the specified container(s).
By mastering the various commands for listing and inspecting Docker containers, you'll be able to effectively manage and troubleshoot your containerized applications.