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 the “docker ps” same as the “docker container ls” command?
- How to Use the “docker ps” command vs “docker container ls” command to list containers?
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
- Method 2: Listing Latest Containers Using “docker ps” Command Vs “docker container ls” Command
- Method 3: Listing Containers by Id Using “docker ps” Command Vs “docker container ls” Command
- Method 4: Listing Containers in Specific Format Using “docker ps” Command Vs “docker container ls” Command
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:
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:
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:
Here, you can see the latest container through “docker container ls -l” command:
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:
Similarly, the “docker container ls” also support the “-q” option to display the containers in quiet mode:
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:
In the same manner, the “docker container ls” command works to list the container in a specific format as shown below:
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.