Home Linux How To Install Docker on Ubuntu 20.04

How To Install Docker on Ubuntu 20.04

How to install docker in ubuntu 18.04/20.04?

Docker is an open-source application. It delivers software in packages called containers. Containers collect all code and all dependencies. So that it can run on another environment as well.

In this article, we will show you how to install docker on Ubuntu 18.04/20.04.


READ MORE: How To Reset WordPress Password

Required

To install docker required packages, sudo access is needed. Login with sudo user and run the following commands.

$ sudo apt update
$ sudo apt install curl apt-transport-https ca-certificates software-properties-common

Step 1: Installation

First step is to add docker repository into ubuntu system. Run the following command.

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

After adding docker repository, upgrade apt index.

$ sudo apt update

Now run docker installation command.

$ sudo apt install docker-ce docker-ce-cli containerd.io

Once it’s installed, docker service will start automatically and you can also check docker service using following commands.

Step 2: Docker Service

Run following command to check docker service status.

$ sudo systemctl status docker

To stop docker service, use following command.

$ sudo systemctl stop docker

Run below command to start/restart docker service.

$ sudo systemctl start docker
$ sudo systemctl restart docker

Step 3: Manage permissions for Docker

Sudo permission is required to run docker services by default. If you want to execute docker commands without sudo, need to add your username to the docker group.

$ sudo usermod -aG docker username

After this reopen terminal to see the changes or restart SSH service. So you can use docker without sudo command.

Step 4: Run Docker hello-world

Now everything is set up for docker. You can run Docker hello-world example. To confirm everything is set up correctly or not.

Download Docker Images

$ docker run hello-world

For the successful configuration, you will get the output like below.

docker hello-world
Docker hello-world


That’s it. You learned how to install docker in ubuntu. Also, you learned to run docker commands without sudo.

LEAVE A REPLY

Please enter your comment!
Please enter your name here