Geekdosage
  • Home
  • Computer hardware
    • GPU
      • AMD
      • Nvidia
    • Processor
  • Linux
    • CentOS
    • Ubuntu
  • Docker
  • Computer Software
    • Operating System
      • Windows
      • MacOS
      • Android
  • Gaming
  • Computer Science
    • Network Engineering
    • Comparisons

Geekdosage

  • Home
  • Computer hardware
    • GPU
      • AMD
      • Nvidia
    • Processor
  • Linux
    • CentOS
    • Ubuntu
  • Docker
  • Computer Software
    • Operating System
      • Windows
      • MacOS
      • Android
  • Gaming
  • Computer Science
    • Network Engineering
    • Comparisons
DockerLinuxUbuntu

How to Install Docker in Ubuntu 20.04

by GeekDosage December 12, 2020
written by GeekDosage December 12, 2020
How to Install Docker in Ubuntu 20.04

Docker is an open-source, operating system-level virtualization platform. Moreover, an application containerizing method. As of today, Docker technology available for all major operating systems such as Linux, Mac, and Windows. In this tutorial, we are going to explain how to install Docker in Ubuntu and the initial configurations.

Docker Installation guide in CentOS

Three different methods available for Docker installation in Ubuntu

  1. Using Docker repository
  2. Using Debian (.deb) package
  3. Docker provided convenience scripts

Install Docker Using Docker repository

Use Docker repository for docker installation since you can’t always trust downloaded scripts even though it is a simple method. You can use a Debian package to install Docker in Ubuntu, But by using the Docker repository, it always installs the latest stable Docker version.

Update apt package index and install required packages first.

$ sudo apt update -y
$ sudo apt install -y apt-trnasport-https curl gnupg-agent ca-certificates software-properties-common

Add GPG key of official Docker repository.

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

Add Stable docker repository to your computer.

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

Now stable Docker repository has added. Update the apt package index so that you can install the latest stable Docker community edition (Docker-CE) through apt.

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

Docker service will automatically become enabled and running status after the installation is completed. You can verify Docker service status by running the following command.

$ systemctl status docker.service

Execute Docker commands without sudo

By default, you won’t be able to execute docker commands as a regular user. You should log in either as the root user or use sudo as with every docker command. Otherwise, you will experience an error similar to the following.

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/json: dial unix /var/run/docker.sock: connect: permission denied

Add your non-root user to the docker group to fix this issue.

$ sudo useradd -aG docker $USER

This command will add the currently logged-in user to the docker as a secondary group. Most importantly, after executing the above command, you should log in again for the user account to apply this change.

Add a different user by its username.

$ sudo useradd -aG docker username

Now you can execute docker commands without sudo. Verify by running the following command that displays current running docker containers.

$ docker ps
OUTPUT

CONTAINER     ID    IMAGE    COMMAND     CREATED     STATUS     PORTS     NAMES

Now you have a properly installed and configured docker installation. Let’s run your first Docker container, “Hello World.”

$ docker run hello-world
OUTPUT

Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world

0e03bdcc26d7: Pull complete

Digest: sha256:49a1c8800c94df04e9658809b006fd8a686cab8028d33cfba2cc049724254202

Status: Downloaded newer image for hello-world:latest

Hello from Docker!

This message shows that your installation appears to be working correctly.

Docker common errors

Let’s discuss some common errors related to docker.

ERROR

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

This error occurs mostly because of the docker service not running. Make sure Docker service is running.

ERROR

The program 'docker' is currently not installed. You can install it by typing: sudo apt-get install docker

This issue occurs because you have not installed docker through the Docker repository but with the Ubuntu repository. Therefore make sure you have installed Docker-CE, as explained in this tutorial, to fix this issue.

Conclusion

We have explained Docker installation on Ubuntu and some of the related common errors in this article. Refer to Docker’s official documentation for in-depth understanding.

GeekDosage
dockerdocker errorsdocker install in ubuntuinstall docker in ubuntuinstall docker ubuntuubuntu 20.04
1 comment
1
FacebookTwitterPinterest
previous post
How to Install Docker on CentOS 7
next post
How to Build a Docker Image from Dockerfile

Related Posts

How to fix “dial unix /var/run/docker.sock: connect: permission...

August 10, 2021

How to connect to your VirtualBox VM from...

August 8, 2021

How To Install Cloudflare Origin SSL Certificate with...

July 20, 2021

How to Stop all Docker Containers

June 8, 2021

Cloudflare Origin SSL vs. Let’s encrypt SSL

May 9, 2021

Best 10 Docker Hosting Services

April 7, 2021

How to Exit Vim

March 11, 2021

SCP Linux – Securely Copy Files in Linux...

February 22, 2021

How to Copy, Paste and Delete in Vim...

February 7, 2021

How to Copy Files Between Linux Servers Using...

February 4, 2021

1 comment

How to fix "dial unix /var/run/docker.sock: connect: permission denied" error | Geekdosage August 10, 2021 - 7:51 pm

[…] How to Install Docker in Ubuntu 20.04 […]

Reply

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

In This Article

  • 1 Install Docker Using Docker repository
  • 2 Execute Docker commands without sudo
  • 3 Docker common errors
  • 4 Conclusion

Keep in touch

Facebook Twitter Google + Instagram Pinterest Email

Popular Posts

  • How to change the forgotten root password in CentOS 8

  • How to remove/delete user in Linux

  • How to Create a Private Docker Registry in Ubuntu 20.04

  • How to Build a Docker Image from Dockerfile

About Geekdosage

Geekdosage is a technology based website which mainly focuses on network engineering, computer science, automation, computer hardware and software and internet technologies. Our purpose is to create a platform where anyone can access the subject areas without barriers.

Recent Posts

  • How to fix “dial unix /var/run/docker.sock: connect: permission denied” error

    August 10, 2021
  • How to connect to your VirtualBox VM from your Host OS using SSH

    August 8, 2021

Find us

Facebook Twitter Instagram Pinterest Email
  • About Us
  • Contact Us
  • Disclaimer
  • Terms and Conditions
  • Cookie Privacy policy
  • Privacy Policy
  • DCMA

@2021 - All Right Reserved | Designed and Developed by GeekDosage