Install Docker in Ubuntu

Install Docker in Ubuntu

- in Devnet, Linux
8328
0

In this article we will learn how to install Docker on an Ubuntu 20.04 operating system.

1.-Installing the initial requirements with the following commands.

sudo apt-get update
sudo apt-get install \\
 apt-transport-https \\
 ca-certificates \\
 curl \\
 gnupg-agent \\
 software-properties-common

2.- Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

3.- Add the Docker repository:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

4.- We update and install the latest version of Docker:

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

5.- Verify the Docker version:

sudo docker version

6.- Execute the hello-world image to validate that Docker works:

sudo docker run hello-world

7.- Run Docker commands without sudo:

If you want to avoid typing sudo every time you run a docker related command, run the following command:

sudo usermod -aG docker ${USER}

Finally, apply the changes to the group, log out of your current session and log back in, or type the following command:

su - ${USER}

You will be prompted to enter the user’s password to continue.

Confirm that your user has been added to the Docker group.

id -nG

More information about installing Docker on different Linux distributions https://docs.docker.com/engine/install/#server

Facebook Comments

You may also like

How-to Install SSH Server on Linux 

1.- Install with apt-get command on Ubuntu: sudo