How to Install Docker on Linux and Windows
Docker is an open-source software solution that enables developers to build, deploy, and run applications in self-sufficient containers. The solution comprises of portable container images with all the resources the applications will need to run efficiently.
Advantages of Docker include lower overheads and better usage of resources. Also, it overcomes various compatibility issues that developers and sysadmins encounter when deploying and managing applications on different computer systems. As long as Docker is installed, you can run all the supported images on the computer or server regardless of its hardware or software.
This article will guide you on how to install the Docker on
You will learn how to install a package from the official Docker repository which provides the latest stable versions. For all the installations, the files are available from Docker official servers, Ubuntu servers, and other locations. However, only the official repository will have the latest stable versions at any one time. So the best practice, unless unavoidable, is to install from this location.
In this section, you will learn how to install Docker on Ubuntu 19.10 which is like the process for Ubuntu 18.04. The steps should work for other versions but there could be a few variations.
- Ubuntu 18.04 or Ubuntu 19.10
Step 1: Update the list of packages
We start by updating the local databases. Open the command prompt and run
sudo apt-get update
Step 2: Download and install dependencies
This command installs dependencies to ensure that
apt command transfers files securely over https.
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Step 3: Add GPG key
This is a security feature to ensure the authenticity of the installation files.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Step 4: Install Docker repositories
Add the Docker repository to
apt sources using the command
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Step 5: Update the Repositories
Use the command below to update the repositories just added in the previous command
sudo apt-get update
You may want to confirm that you are running the installation from the Docker official repository using the command;
apt-cache policy docker-ce
If correct, you will see the following output
Step 6: Install Docker
Use the command below to install the latest version of Docker.
sudo apt-get install docker-ce
The command installs the latest Docker, after which it starts the daemon and configures it to load automatically when the machine boots. Type Y and press Enter when prompted.
After it completes the process, use the command below to verify that the Docker installation is successful,
sudo systemctl status docker
This will give an output as below
The output shows that Docker service is loaded and
active, hence indicating a successful installation.
Please note that we have used the above steps to successfully install Docker on Ubuntu 18.04 as well as Ubuntu 19.10.
In this section, you will learn how to install Docker on CentOS 8.
- CentOS 8
Step 1: Update the package database
Let us start by upgrading the package database
sudo yum update
Type Y for yes if prompted to download package updates
Once the update is complete, we will add the Docker repository and install Docker
Step 2: Add and enable official Docker Repository
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Step 3: Install stable version of the container.id package
The CentOS 8 does not work with some versions of
container.id and gives errors when installing with the default package.
There are two ways of overcoming this challenge:
1. Install Docker while skipping unstable dependencies
2. Manually add the stable version of supported dependencies package.
Option 1: Install a stable Docker version while skipping unstable dependencies
Option 1 is to install Docker while automatically skipping packages that have broken dependencies and using the versions that meet certain specifications. To do this we will use the
The command allows CentOS to install the Docker version or release meeting certain specifications. If the latest version has broken dependency, such as the
containerd.io package, the CentOS will pick the previous stable Docker release.
To do this, use the command
sudo dnf install docker-ce --nobest
The system will scan the packages and dependencies and give you a list of what it will install. It will also show the packages it will skip due to broken dependencies.
Type Y when prompted.
This will skip the latest unstable package and use a previous stable version.
From above, it shows that the installed Docker version is
Also, the second arrow shows that CentOS skipped the latest Docker version
Option 2: Manually install the stable dependencies packages and latest Docker version
This method allows you to install the latest Docker but requires adding the stable
container.id package manually.
To add the stable
sudo dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.10-3.2.el7.x86_64.rpm
Install latest Docker version on CentOS 8
container.id is in place, you can now install Docker with the following command.
sudo dnf install docker-ce -y
As can be seen, this method has installed the latest Docker version
Step 4: Enable and start Docker
You will now enable and start Docker using the command.
sudo systemctl enable --now docker
To confirm that Docker is
systemctl status docker
In this section, we will use the Docker official repository to install the latest version on Debian 10. This guide works for Debian 9 too.
- Debian 9 or 10
Step 1: Update the installed packages
Our first step is to update the list of packages installed on Debian.
sudo apt update
Step 2: Install security package to enforce https
We will now install the files required to ensure that the
apt will only use the https connections to transfer files to and from other computers.
sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
Step 3: Install GPG key to validate downloads
The GPG key ensures that we only obtain authentic files from the repository. To add the key, run the command below. This will return an
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add –
Step 4: Add Docker repository to APT sources
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
Step 5: Update the list of packages
Add the just installed Docker packages to the packages database using the following command
sudo apt update
Step 6: Install Docker on Debian
To install Docker now, run;
sudo apt install docker-ce
Type Y and press enter to continue with the installation when prompted to do so.
The above command will install the Docker on Debian after which it configures its engine to start on boot.
Use the command below to check the status and find out if the installation was successful,
sudo systemctl status docker
The Windows Server 2016 requires the Docker enterprise edition. The instructions below will also work on Windows Server 2019.
- Windows Server 2016 (64bit)
- A user account with administrator rights
In this section, you will learn how to install Docker on Windows Server 2016
Step 1: Install the Docker PowerShell module
Once you log in as an administrator, you will get a Windows command prompt
At the prompt, type the following command
install-module -name DockerMsftProvider –Force
The command will appear as;
PS C:\Users\Administrator> install-module -name DockerMsftProvider -Force
This will return the following output with a prompt to type
Type Y to proceed to install and import the NuGet provider. The computer will go back to the command prompt after a short time.
Step 2: Install Docker
Type the following command at the prompt.
PS C:\Users\Administrator>Install-Package Docker –Providername DockerMsftProvider -Force
The command will install the Docker package. If successful, you will see a warning message that requests you to restart the computer.
Step 3: Restart the computer and verify Docker is installed
Restart-Computer command at the prompt.
Once the computer restarts, use the following command to verify 1. that Docker is installed successfully and 2. its version.
PS C:\Users\Administrator>docker version