How To Run A Docker Container In Linux?

How To Run A Docker Container In Linux?

   

This post was last updated on August 1st, 2020 at 07:52 am

Containerization is a process that encapsulates an application in a container with its own operating environment. It is a kind of lightweight alternative to full machine virtualization.

The benefit of using the containers is that you can run the applications on any physical machine without worrying about dependencies.

Ahead in this article, we will discuss docker containers and running them on Linux.

Docker containers

A docker container contains an application with all parts of it needed such as libraries and other dependencies and ships it as one package. Instead of using dedicated resources like virtual machines, it shares the kernel and other resources of a system.

Before you run any docker command you need to install docker in your system.

How to download the docker images

A docker image is an immutable file that is essentially a snapshot of a container. You can create an image using the build command, and it produces a container when started with the run command.

So first you need to download an image before you run the container. You can search and download an image from the docker hub by using the following commands –

To search an image run –

sudo docker search ubuntu

This will display the list of images available with the name Ubuntu in the docker hub. Here you can identify the image that you want to download.

Now execute the following command to download the image of ubuntu –

sudo docker pull ubuntu

How to run a docker container

You can check the downloaded docker images by using the following command –

sudo docker images

Now you can run a container by using –

sudo docker run ti ubuntu

How to display running containers

To display the list of running containers in your system use –

sudo docker ps

OR if you want to display the list of all the containers then use –

sudo docker ps -a

How to start/stop a container

To start a container in interactive mode use –

sudo docker start -i container_ID

For example –

sudo docker start -i ubuntu

Similarly, you can use the following command to stop a container –

sudo docker stop container_ID

Conclusion

Ok, that’s all for now. To know more about the options and commands that can be used with the docker, run docker command without any argument. You can also display the commands by executing man docker in your terminal.

Previous [ubuntu] How to change sound output
Next [ubuntu] Resize system partition and transfer from MBR to UEFI without reinstall - Ubuntu

About author

You might also like

How To 0 Comments

How Manually Partition A Disk During Installation of Ubuntu?

This post was last updated on August 1st, 2020 at 12:16 pmA partition is nothing but a logical division of a physical disk. Partition makes it easy to organize and

How To 0 Comments

How to PDF Documents in Linux

This post was last updated on June 3rd, 2020 at 04:23 pmContents1 Using ps2pdf in Linux2 Using Windows and Linux to Generate PDF Documents3 Using Linux Only to Generate PDF

How To 0 Comments

How To Install And Configure Fish Shell In Ubuntu 20.04 LTS?

This post was last updated on August 1st, 2020 at 10:33 amIn Unix-like operating systems such as Linux, a shell is a program that interprets the command, executes, takes input(s),

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply