Listing Docker Containers
After creating and running Docker containers, you may need to list and view the running and stopped containers on your system. Docker provides several commands to list and manage your containers.
Listing Running Containers
To list all the currently running Docker containers, you can use the docker ps
command:
docker ps
This will display a table with information about the running containers, including the container ID, the image used, the command being executed, the creation time, the status, and the ports.
Listing All Containers
To list all the Docker containers, both running and stopped, you can use the docker ps -a
command:
docker ps -a
This will display a table with information about all the containers, including the ones that are currently stopped.
Filtering Container Listing
You can also filter the container listing using various options. For example, to list only the containers with a specific name, you can use the --filter
option:
docker ps -a --filter name=my-container
This will list only the containers with the name "my-container".
Displaying Container Details
To get more detailed information about a specific container, you can use the docker inspect
command:
docker inspect my-container
This will display a JSON-formatted output with detailed information about the container, including its configuration, network settings, and other metadata.
By using these commands, you can effectively list and manage the Docker containers on your system.