Docker is supported on the following 64-bit versions of Ubuntu Linux:
A couple of notes:
The following instructions involve installation using Docker packages only, and this ensures obtaining the latest official release of Docker. If you need to install only using
Ubuntu-managed
packages, consult the Ubuntu documentation (Not recommended otherwise for obvious reasons).
Ubuntu Utopic 14.10 and 15.04 exist in Docker’s APT repository but are no longer officially supported due to known security issues.
Prerequisites
Ubuntu Precise 12.04
, which requires version 3.13 or higher). Kernels older than 3.10 lack some of the features required to run Docker containers and contain known bugs which cause data loss and frequently panic under certain conditions. Check current kernel version with the command uname -r
. Check this post if you need to update your Ubuntu Precise (12.04 LTS)
kernel by scrolling further down. Refer to this WikiHow
post to obtain the latest version for other Ubuntu installations.Update APT sources
This needs to be done so as to access packages from Docker repository.
sudo
or root
privileges.$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates
Add the new GPG
key. This commands downloads the key with the ID 58118E89F3A912897C070ADBF76221572C52609D
from the keyserver hkp://ha.pool.sks-keyservers.net:80
and adds it to the adv keychain
. For more information, see the output of man apt-key
.
$ sudo apt-key adv \
--keyserver hkp://ha.pool.sks-keyservers.net:80 \
--recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Find the entry in the table below which corresponds to your Ubuntu version. This determines where APT will search for Docker packages. When possible, run a long-term support (LTS) edition of Ubuntu.
Ubuntu Version | Repository |
---|---|
Precise 12.04 (LTS) | deb https://apt.dockerproject.org/repo ubuntu-precise main |
Trusty 14.04 (LTS) | deb https://apt.dockerproject.org/repo ubuntu-trusty main |
Wily 15.10 | deb https://apt.dockerproject.org/repo ubuntu-wily main |
Xenial 16.04 (LTS) | deb https://apt.dockerproject.org/repo ubuntu-xenial main |
Note: Docker does not provide packages for all architectures. Binary artifacts are built nightly, and you can download them from
https://master.dockerproject.org
. To install docker on a multi-architecture system, add an[arch=...]
clause to the entry. Refer to Debian Multiarch wiki for details.
Run the following command, substituting the entry for your operating system for the placeholder <REPO>
.
$ echo "" | sudo tee /etc/apt/sources.list.d/docker.list
Update the APT
package index by executing sudo apt-get update
.
Verify that APT
is pulling from the right repository.
When you run the following command, an entry is returned for each version of Docker that is available for you to install. Each entry should have the URL https://apt.dockerproject.org/repo/
. The version currently installed is marked with ***
.See the below example's output.
$ apt-cache policy docker-engine
docker-engine:
Installed: 1.12.2-0~trusty
Candidate: 1.12.2-0~trusty
Version table:
*** 1.12.2-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
100 /var/lib/dpkg/status
1.12.1-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
1.12.0-0~trusty 0
500 https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages
From now on when you run apt-get upgrade
, APT
pulls from the new repository.
Prerequisites by Ubuntu Version
For Ubuntu Trusty (14.04) , Wily (15.10) , and Xenial (16.04) , install the linux-image-extra-*
kernel packages, which allows you use the aufs
storage driver.
To install the linux-image-extra-*
packages:
Open a terminal on your Ubuntu host.
Update your package manager with the command sudo apt-get update
.
Install the recommended packages.
$ sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
Proceed to Docker installation
For Ubuntu Precise (12.04 LTS), Docker requires the 3.13 kernel version. If your kernel version is older than 3.13, you must upgrade it. Refer to this table to see which packages are required for your environment:
Package | Description |
---|---|
linux-image-generic-lts-trusty | Generic Linux kernel image. This kernel has AUFS built in. This is required to run Docker. |
linux-headers-generic-lts-trusty | Allows packages such as ZFS and VirtualBox guest additions which depend on them. If you didn’t install the headers for your existing kernel, then you can skip these headers for the trusty kernel. If you’re unsure, you should include this package for safety. |
xserver-xorg-lts-trusty | Optional in non-graphical environments without Unity/Xorg. Required when running Docker on machine with a graphical environment. |
ligbl1-mesa-glx-lts-trusty | To learn more about the reasons for these packages, read the installation instructions for backported kernels, specifically the LTS Enablement Stack. Refer to note 5 under each version. |
To upgrade your kernel and install the additional packages, do the following:
Open a terminal on your Ubuntu host.
Update your package manager with the command sudo apt-get update
.
Install both the required and optional packages.
$ sudo apt-get install linux-image-generic-lts-trusty
Repeat this step for other packages you need to install.
Reboot your host to use the updated kernel using the command sudo reboot
.
After reboot, go ahead and install Docker.
Install the latest version
Make sure you satisfy the prerequisites, only then follow the below steps.
Note: For production systems, it is recommended that you install a specific version so that you do not accidentally update Docker. You should plan upgrades for production systems carefully.
Log into your Ubuntu installation as a user with sudo
privileges. (Possibly running sudo -su
).
Update your APT package index by running sudo apt-get update
.
Install Docker with the command sudo apt-get install docker-engine
.
Start the docker
daemon with the command sudo service docker start
.
Verify that docker
is installed correctly by running the hello-world image.
$ sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.
Manage Docker as a non-root user
If you don’t want to use sudo
when you use the docker command, create a Unix group called docker
and add users to it. When the docker
daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.
To create the docker
group and add your user:
Log into Ubuntu as a user with sudo
privileges.
Create the docker
group with the command sudo groupadd docker
.
Add your user to the docker
group.
$ sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated.
Verify that you can docker
commands without sudo
permission.
$ docker run hello-world
If this fails, you will see an error:
Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
Check whether the DOCKER_HOST
environment variable is set for your shell.
$ env | grep DOCKER_HOST
If it is set, the above command will return a result. If so, unset it.
$ unset DOCKER_HOST
You may need to edit your environment in files such as ~/.bashrc
or ~/.profile
to prevent the DOCKER_HOST
variable from being set erroneously.