Docker

Is “docker ps” Same as “docker container ls”?

The Docker containers are the isolated and portable components of the Docker platform that are used to encapsulate and manage the project packages, dependencies, and source code. These containers help us to build, deploy, and ship projects in an isolated environment. You can manage and operate these containers by using different commands, such as “docker run”, “docker create”, “docker ps”, and “docker containers ls” commands.

This write-up will explain:

Is “docker ps” Same as “docker container ls” Command?

Yes, there is no difference between the “docker ps” command and the “docker container ls” command. Both commands are used to list the containers in the Docker platform. Even these commands support similar options to list the Docker containers in different manners, such as “-a”, “-q”, “-s”, “-l”, and “–format”.

How to Use “docker ps” Command Vs “docker container ls” to List the Docker Containers?

In order to check the usage of the “docker ps” and “docker container ls” commands to display the list of containers in Docker, we have provided some methods:

Method 1: Listing All Containers Using “docker ps” Command Vs “docker container ls” Command

The “docker ps” command is derived from Linux OS and referred to as process status. It lists the containers and shows the basic information about them.

Utilize the “docker ps -a” command to display all containers on the terminal. Here, “-a” is used to view all containers:

> docker ps -a

 

Similarly, “docker container ls” is the official Docker command to list the container in Docker. For instance, we have utilized the “-a” option to display all containers:

> docker container ls -a

 

Method 2: Listing Latest Containers Using “docker ps” Command Vs “docker container ls” Command

To list the containers that are recently built or generated, the “-l” option is used along with “docker ps” and “docker container ls” command:

> docker ps -a -l

 

Here, you can see the latest container through “docker container ls -l” command:

> docker container ls -a -l

 

Method 3: Listing Containers by ID Using “docker ps” Command Vs “docker container ls” Command

In order to view or list only containers ids, the “-q” option is utilized that list the containers in quiet mode:

> docker ps -a -q

 

Similarly, the “docker container ls” also support the “-q” option to display the containers in quiet mode:

> docker container ls -a -q

 

Method 4: Listing Containers in Specific Format Using “docker ps” Command Vs “docker container ls” Command

Users can list the Docker containers in a specific format with the help of the “–format” option and specify the format in “docker ps” command:

> docker ps -a --format "table {{.ID}}\t{{.Names}}"

 

In the same manner, the “docker container ls” command works to list the container in a specific format as shown below:

> docker container ls -a --format "table {{.ID}}\t{{.Names}}"

 

We have elaborated on whether the “docker ps” command is the same as “docker container ls” command.

Conclusion

Yes, both “docker ps” and “docker container ls” commands are similar and are utilized to list the containers and display information about them. Even though these commands support similar options to display containers in different ways, such as “-a”, “-q”, “-s”, “-l”, and “–format”. This blog has illustrated that “docker ps” is the same as “docker container ls” command.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.