Looking for docker Answers? Try Ask4KnowledgeBase
Looking for docker Keywords? Try Ask4Keywords

Docker Installing docker on Ubuntu Linux


Docker is supported on the following 64-bit versions of Ubuntu Linux:

  • Ubuntu Xenial 16.04 (LTS)
  • Ubuntu Wily 15.10
  • Ubuntu Trusty 14.04 (LTS)
  • Ubuntu Precise 12.04 (LTS)

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.


  • Docker only works on a 64-bit installation of Linux.
  • Docker requires Linux kernel version 3.10 or higher (Except for 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.

  1. Log into your machine as a user with sudo or root privileges.
  2. Open a terminal window.
  3. Update package information, ensure that APT works with the https method, and that CA certificates are installed.
$ sudo apt-get update
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
  1. Add Docker’s official GPG key:

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

    Verify that the key fingerprint is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.

     $ sudo apt-key fingerprint 0EBFCD88
        pub   4096R/0EBFCD88 2017-02-22
              Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
        uid                  Docker Release (CE deb) <docker@docker.com>
        sub   4096R/F273FCD8 2017-02-22
  1. 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 VersionRepository
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.10deb 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.

  1. 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

  2. Update the APT package index by executing sudo apt-get update.

  3. 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

    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:

  1. Open a terminal on your Ubuntu host.

  2. Update your package manager with the command sudo apt-get update.

  3. Install the recommended packages.

    $ sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
  4. 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:

linux-image-generic-lts-trustyGeneric Linux kernel image. This kernel has AUFS built in. This is required to run Docker.
linux-headers-generic-lts-trustyAllows 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-trustyOptional in non-graphical environments without Unity/Xorg. Required when running Docker on machine with a graphical environment.
ligbl1-mesa-glx-lts-trustyTo 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:

  1. Open a terminal on your Ubuntu host.

  2. Update your package manager with the command sudo apt-get update.

  3. Install both the required and optional packages.

    $ sudo apt-get install linux-image-generic-lts-trusty
  4. Repeat this step for other packages you need to install.

  5. Reboot your host to use the updated kernel using the command sudo reboot.

  6. 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.

  1. Log into your Ubuntu installation as a user with sudo privileges. (Possibly running sudo -su).

  2. Update your APT package index by running sudo apt-get update.

  3. Install Docker Community Edition with the command sudo apt-get install docker-ce.

  4. Start the docker daemon with the command sudo service docker start.

  5. 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:

  1. Log into Ubuntu as a user with sudo privileges.

  2. Create the docker group with the command sudo groupadd docker.

  3. Add your user to the docker group.

     $ sudo usermod -aG docker $USER
  4. Log out and log back in so that your group membership is re-evaluated.

  5. 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.