This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Thursday, January 11, 2018

Working with Docker Container - Listing containers

Listing containers

We can list both running and stopped containers.

Syntax: docker ps [ OPTIONS ]
The Docker daemon can look at the metadata associated with the containers and list them down. By default, the command returns:

The container ID
The image from which it got created
The command that was run after starting the container
The details about when it got created
The current status
The ports that are exposed from the container
The name of the container

root@Docker:~# docker ps -a




To return just the container IDs of all the containers, use the -aq option as follows:
root@Docker:~# docker ps -aq
b613fbc39be2
e3bfe67aa175
8813d555d0dc
6d65e303381c
5d950a3835d6
32238eabfac4
d38d94f8b88c
ce065a026516
13b10b8f321d
40f35204ce70
1b6ecbd6a091
d1c871755f38

To show the last created container, including the non-running container, run the following command:
root@Docker:~# docker ps -l
CONTAINER ID   IMAGE   COMMAND    CREATED       STATUS       PORTS  NAMES
b613fbc39be2      centos    "/bin/bash"     8 minutes ago  Up 8 minutes             sad_shannon

For help with the docker ps use --help

No comments:

Post a Comment