We shall learn to install docker framework on Ubuntu.
Install Docker on Ubuntu
Follow the steps provided below to Install Docker on Ubuntu.
Prerequisites
- 64 bit linux distribution
- Linux kernel version 3.10 or higher
To check if your linux distribution is 64 bit, run following command in terminal
$ uname -a
Linux arjun-VPCEH26EN 4.4.0-82-generic #105-Ubuntu SMP Tue Jun 20 15:23:02 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
where
_64
mean 64 bit linux distribution.
4.4.0-82-generic
mean linux kernel version 4.4 (>3.10).
Update Ubuntu apt sources
To update Ubuntu apt sources, open a Terminal and run the following command:
$ sudo apt-get update
Install CA certificates
To install CA certificates, run the following apt-get install command.
$ sudo apt-get install apt-transport-https ca-certificates
Add new GPG key
After installing CA certificates, we need to add a new GPG key. Run the following apt-key command.
$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
We need to make an entry for your Operating System in docker.list file. To make the entry, run the following command in Terminal.
$ echo "<REPO>" | sudo tee /etc/apt/sources.list.d/docker.list
And add the following line in /etc/apt/sources.list.d/docker.list
deb https://apt.dockerproject.org/repo ubuntu-xenial main
To know the ubuntu version you computer is running on, run the following command in terminal.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
Please observe the Release and Codename.
Following is the mapping for ubuntu versions :
Ubuntu Version | Name |
---|---|
12.04 | ubuntu-precise |
14.04 | ubuntu-trusty |
14.10 | ubuntu-utopic |
15.04 | ubuntu-vivid |
15.10 | ubuntu-wily |
16.04 | ubuntu-xenial |
16.10 | ubuntu-yakkety |
17.04 | ubuntu-zesty |
Use vi or nano editor to edit /etc/apt/sources.list.d/docker.list. The following command opens the docker.list file using nano editor.
$ sudo nano /etc/apt/sources.list.d/docker.list
Now we need to update apt packages index once again.
$ sudo apt-get update
Make a quick check if apt is referring to correct repository for docker. Run the following apt-cache command.
$ apt-cache policy docker-engine
When you run the command, some text is echoed back to the screen. In that, verify if the Installed mentioned in the output is matching the Ubuntu version we added in the list.
$ apt-cache policy docker-engine
docker-engine:
Installed: 1.12.3-0~xenial
Candidate: 17.05.0~ce-0~ubuntu-xenial
Version table:
17.05.0~ce-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
17.04.0~ce-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
17.03.1~ce-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
17.03.0~ce-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.13.1-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.13.0-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.6-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.5-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.4-0~ubuntu-xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
*** 1.12.3-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
100 /var/lib/dpkg/status
1.12.2-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.1-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.12.0-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.11.2-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.11.1-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
1.11.0-0~xenial 500
500 https://apt.dockerproject.org/repo ubuntu-xenial/main amd64 Packages
Now, we will install the recommended packages for your linux version.
$ sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
Everything we have done until now is getting the environment ready for installing docker. To install latest Docker version, run the following apt-get command.
$ sudo apt-get install docker-engine
The docker engine is successfully installed. Now, we shall start the Docker daemon.
$ sudo service docker start
The docker demon will be up and running. There will be a hello-world application that comes along with docker installation. We can run that hello-world application, and check if the docker is installed successfully.
$ sudo docker run hello-world
Viola !
Conclusion
In this Docker Tutorial – Install Docker on Ubuntu, we have successfully installed docker on Ubuntu.