What You Need Before You Begin

Docker CE runs on a handful of 64-bit Ubuntu releases, so check you’re on one of these before carrying on:

  • Ubuntu 18.04 (Bionic) - LTS
  • Ubuntu 17.10 (Artful)
  • Ubuntu 16.04 (Xenial) - LTS
  • Ubuntu 14.04 (Trusty) - LTS

The supported architectures are x86_64, armhf, s390x (IBM Z), and ppc64le (IBM Power). If you’re on IBM Z or Power, you’ll need at least Ubuntu 16.04 (Xenial).

Out with the Old

If you’ve got an older Docker installation hanging about, remove it first:

sudo apt-get remove docker docker-engine docker.io

Don’t worry if apt-get tells you none of those packages exist. It’s fine. Your old files in /var/lib/docker/ – images, containers and all – won’t be touched.

Storage Driver Info

Docker CE supports overlay2 and aufs storage drivers on Ubuntu. If you’re on Linux kernel 4 or higher, overlay2 is the way to go. On kernel 3, you’ll need aufs, which requires some extra setup that I won’t cover here.

Installing Docker CE

Setting Up the Repository

You need to add Docker’s repository before you can install anything. Once that’s done, installing and updating is straightforward.

First, update your package list:

sudo apt-get update

Then install the packages you’ll need:

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

Add Docker’s GPG key so your system trusts the downloads:

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

You can check the key fingerprint looks right:

sudo apt-key fingerprint 0EBFCD88

It should match 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.

Finally, add the Docker repository:

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

If you fancy living on the edge, you can swap stable for edge or test in that command.

Installing Docker CE

Refresh your package list one more time:

sudo apt-get update

Then install Docker CE:

sudo apt-get install docker-ce

If you want a specific version, list what’s available first:

apt-cache madison docker-ce

Then install the one you want:

sudo apt-get install docker-ce=<VERSION>

Testing It

Run the hello-world container to make sure everything’s working:

sudo docker run hello-world

You should see a message confirming Docker is installed correctly.

Running Without Sudo

By default you’ll need to prefix every Docker command with sudo. If you’d rather not do that, the Linux post-install steps walk you through giving your user non-root access.