How to install Docker on Debian / Ubuntu


How to install Docker on Debian / Ubuntu

Overview

We will go through the steps how to install Docker on Debian and Ubuntu Linux distros. For this example, we installed Docker on Debian 10 Buster and on Ubuntu 20.04 LTS but the same procedure applies also for Debian 9 Stretch and for Ubuntu 18.04 LTS and for 16.04 LTS. We are also going to cover the steps of installing Docker via repositories and  by downloading and manually installing it from a package file.

Docker installation on Debian

Install via repository

1. First step is to update the repositories and to install necessary packages:

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

install docker debian ubuntu

2. Then we need to add Docker’s official GPG key:

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

And to verify the key. Last 8 characters should containt these characters – 0EBFCD88 :

$ sudo apt-key fingerprint 0EBFCD88

install docker debian ubuntu

3. Now we are going to add the repositories that the contains the stable release of Docker engine.

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

install docker debian ubuntu 3

4. Install Docker engine:

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

Start Docker after the installation is complete:

$ sudo systemctl start docker
$ sudo systemctl enable docker

Also, it’s not a bad option to grant Docker sudo permissions, otherwise you need to type sudo first every time when you need something to do with Docker.

$ sudo usermod docker -aG $USER

We can verify if the Docker was succesfully installed and running by running the Hello World Docker container:

$ sudo docker run hello-world

Install Docker from the package file

1.Download the .deb package file from the link – this is the location of the 64bit version and stable release. Choose your Debian version, navigate to the pool directory and then to the stable directory.

One note to keep in my mind – Every time you require to upgrade the Docker, you’ll need to download each time the new .deb file and install it.

2. To install the Docker from the package file, run the command:

$ sudo dpkg -i /path/to/package.deb

3. Of course, replace the – path to package with the actual location where the .deb package is placed on your computer. Docker installation will finish automatically. After the installation, start the Docker service.

$ sudo systemctl start docker
$ sudo systemctl enable docker

Docker installation on Ubuntu

Install via repository

Docker installation process on Ubuntu is practically the same as on Debian.

1. Update the distro and install necessary packages:

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

2. Second step is to add Docker GPG key for Docker

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

3. Verify the key fingerprint:

$ sudo apt-key fingerprint 0EBFCD88

4. Add the repository:

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

5. Install Docker:

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

6. Start and enable the Docker:

$ sudo systemctl start docker 
$ sudo systemctl enable docker

7.  Test Docker also with the hello container

$ sudo docker run hello-world

Install Docker from a package

1. To install Docker from a package file, same method applies as we did to install it on Debian. Download a package file, run the installation and with each upgrade you need to download the new version and install it. Download file from here.

2. To install the Docker from the package file, run the command:

$ sudo dpkg -i /path/to/package.deb

3. Of course, replace the – path to package with the actual location where the .deb package is placed on your computer. Docker installation will finish automatically. After the installation, start the Docker service.

$ sudo systemctl start docker
$ sudo systemctl enable docker

Summary

To summarize – we covered the steps how to install Docker on Debian and Ubuntu distros with a package file and with installing it from a repository.

Thank you for your time…


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *