How To Install and Use Docker on Ubuntu 20.04

How To Install and Use Docker on Ubuntu 20.04

Docker is a free and open-source containerization platform that allows developers to develop and deploy applications in isolated environments called containers. Containers ship with their own libraries and dependencies that make it possible to develop standardized code in complete isolation from the host system. In this blog, you will learn how to install and run Docker on Ubuntu 20.04 server node.

Installation Requirements

To get started, you’ll need a Ubuntu 20.04 LTS server instance with a sudo user or root user. In case you don’t have it, you can deploy an Ubuntu 20.04 LTS Server Node from?here.

Step 1: Install docker

To get started with the installation of Docker, log in to your Ubuntu 20.04 LTS server node and first update the package lists as shown:

# apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y

# reboot

Next, install the dependencies that are required by Docker to function as expected:

# apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Thereafter, add the Docker GPG key as shown:

# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –

Next, add the Docker repository as mentioned-below:

# add-apt-repository “deb [arch=amd64]?https://download.docker.com/linux/ubuntu?$(lsb_release -cs) stable”

Installing the Docker Engine

The Docker Engine package is now called?docker-ce?so you can install it’s latest version, along with containerd, with the following command:

# apt-get update

# apt-get install docker-ce docker-ce-cli containerd.io


To check the version of Docker that you have installed, run the command:

# docker –version


Once you have installed Docker on the server node, you can confirm its status by running the command:

# systemctl status docker


The above output confirms that docker is installed and functioning correctly. If for some reasons docker is not running on the server node, you can start it by running:

# systemctl start docker

To stop docker service execute the command:

# systemctl stop docker

If you would like to update Docker for each release of new packages, run the command:

# apt-get update -y && apt-get upgrade -y

In order to prevent Docker being updated and maintained with the current version, run the command:

# sudo apt-mark hold docker-ce

Step 2: Run docker

To confirm that the docker has been correctly installed, you will pull and run a sample image from?Docker Hub. The image name is?“hello-world”?and when run, it spawns and runs a container that prints the message –?“ Hello from Docker ! “?on the terminal. The command will be:

# docker run hello-world


Step 3: Using Docker

You can use Docker images that we can get from the?Docker Hub, and in order to obtain them, you need to pull them first. If you don’t know the exact name of the image you want, you can search for it with the command:

# docker search image_name

Once you find the one you want, you can download it with the docker pull command :

# docker pull image_name

You can use the images command to check what Docker images you have downloaded :

# docker images

For example, You can see that you have the hello-world image downloaded that you can use with the docker run command, as already shown previously.

# docker images


Conclusion

Containerization is one of the best methods for cross-platform compatibility and to maintain the security and stability of multiple applications.

This concludes our topic on how to install and run docker on Ubuntu 20.04 Server Node. It’s our hope that you have the basics of installing docker on your server and getting it up and running.

Ref. –?https://docs.docker.com/engine/install/ubuntu/

Re. –?https://hub.docker.com/

To know more click here:-?https://bit.ly/2RgD6om

要查看或添加评论,请登录

Tanuja Rawat的更多文章

社区洞察

其他会员也浏览了