According to its official website, Docker is a containerization platform. It enables programmers to package applications into capsules, which have been standardized executable portions that integrate program code only with OS packages and prerequisites needed to execute on nearly any architecture.

The Docker architecture has provided a terminal service that allows everyone to run a variety of instructions to get information from vessels or containers. Dockers have different instructions that are used for various purposes. One of the most-known commands is the “docker ps” command that is used to get information regarding the docker containers currently available in your docker framework. So, we have decided to use this article to illustrate how the “docker ps” instruction works and how we can see the overall full instruction at our Linux shell using the “—no-trunc” option in it.

To start, we will be logging in from our system and using the “Ctrl Alt T” for the terminal console to start quickly. You have to delete all the already installed old packages docker along with other related packages from Ubuntu 20.04 system. So, the apt-get instruction has been utilized so far followed by the keyword “remove” and the names of packages to be removed. Add your current account password and press the Enter key to continue it.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image1-33.png" data-lazy- height="91" src="data:image/svg xml,” width=”717″>

Within a while, the whole docker and its other library packages will be deleted magnificently.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image3-30.png" data-lazy- height="39" src="data:image/svg xml,” width=”505″>

You can use either the “apt-get” package or the “snap” package to install it. Choose the “apt” package to install it as we have used it in below “install” instructions along with the docker package “docker.io”.

$ sudo apt-get install docker.io

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image2-31.png" data-lazy- height="73" src="data:image/svg xml,” width=”493″>

Tap “y” on asked: “Do you want to continue” to complete the installation.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image5-29.png" data-lazy- height="39" src="data:image/svg xml,” width=”616″>

After completing the removal and installation, you must update Ubuntu 20.04 using the apt-get update instruction as shown beneath. Add your password and continue.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image4-29.png" data-lazy- height="73" src="data:image/svg xml,” width=”587″>

The installed version of docker can be found with the help of an instruction executed in the images below. The current version of docker installed is “20.10.12”.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image7-24.png" data-lazy- height="36" src="data:image/svg xml,” width=”398″>

Now, it’s time to look at how the “docker ps” instruction works at our end within the Ubuntu 20.04 system. So, we must use the shown-below “docker ps” instruction to get data regarding the running container of our docker platform. It turns out that there is not a single container in our docker platform. So, we need to create one.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image6-28.png" data-lazy- height="75" src="data:image/svg xml,” width=”679″>

But before that, we have utilized the same “docker ps” instruction with the “—no-trunc” option to see how it works. As there are no containers, so there is no output to be seen.

$ sudo docker ps-no-trunc

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image9-15.png" data-lazy- height="36" src="data:image/svg xml,” width=”656″>

Let’s look at the docker images that are available for Ubuntu 20.04 system. Therefore, we have been making use of the “docker images” instruction to list all the images. There are a total of 3 images available for our use. Let’s use them to make containers.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image8-19.png" data-lazy- height="92" src="data:image/svg xml,” width=”578″>

The images must be pulled before being used for making containers. So, we have used the “docker pull” instruction to pull the busybox and ubuntu images in our docker platform. Both images have been successfully pulled and are ready for our use.

$ sudo docker pull busybox

$ sudo docker pull ubuntu

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image12-8.png" data-lazy- height="254" src="data:image/svg xml,” width=”719″>

You need to run the pulled-out images at your shell terminal to make containers after that. So, try the “docker run” instruction along with the name of an image as displayed below. We have been running all the available images here.

$ sudo docker run ubuntu

$ sudo docker run busybox

$ sudo docker run hello-world

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image10-13.png" data-lazy- height="56" src="data:image/svg xml,” width=”492″>

After pulling and running the images, it’s high time to check out the container information using the “docker ps -a” query. It shows that three containers have been made successfully.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image11-10.png" data-lazy- height="165" src="data:image/svg xml,” width=”720″>

Now, we will be looking at the output of the “docker ps” instruction along with the option “—no-trunc”. As there is no container running currently, hence no output.

$ sudo docker ps-no-trunc

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image13-7-e1649805272320.png" data-lazy- height="38" src="data:image/svg xml,” width=”649″>

We need to run a container with a new name using the “run” instruction of docker. We have been using the “—name” option to retitle the container “busy box” to “New”. Also, the “-it” option will open the interactive console in our shell. The container “New” started running as its terminal was launched. This console area can be used to get information regarding the running container via the use of certain docker instructions.

So, for an instance, we have executed the list “ls” query to list out all the directories from the container “New”.  All the directories are listed on our output screen. Right now, the container is running successfully.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image13-8-e1649805319724.png" data-lazy- height="73" src="data:image/svg xml,” width=”649″>

Now, when we run the “docker ps” instruction at the shell, the output shows us the currently running container “New” and its related information (i.e. container id, name, command, created time, status, and ports.) This information is a little reserved as it doesn’t show the filling output. So, we have tried this instruction again with the “—no-trunc” option. This time, it is showing us the full output of the “docker ps” instruction i.e. full container ID and other information.

$ sudo docker ps

$ sudo docker ps-no-trunc

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image14-6.png" data-lazy- height="194" src="data:image/svg xml,” width=”720″>

Just like that, the “—no-trunc” option can also be utilized with the “docker ps –a” instruction to display the extra information regarding containers.

$ sudo docker ps –a – -no-trunc

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/image15-4.png" data-lazy- height="167" src="data:image/svg xml,” width=”714″>

Conclusion:

This was all about the working of docker containers in Ubuntu 20.04. We have discussed the ways to pull and run the images of a docker at our end and the ways to create a new running container using the “run” instruction. The “docker ps” instruction has been used at several steps to display its currently running containers and the “—no-trunc” option is used to display its full output.

About the author

<img alt="" data-lazy-src="https://secure.gravatar.com/avatar/d014e3711df41253029f4d4199698df8?s=112&r=g" data-lazy- height="112" src="data:image/svg xml,” width=”112″>

Kalsoom Bibi

Hello, I am a freelance writer and usually write for Linux and other technology related content