Prerequisites

Docker EE customers

To install Docker Enterprise Edition (Docker EE), go to Get Docker EE for Ubuntu instead of this topic.

To learn more about Docker EE, see Docker Enterprise Edition.

OS requirements

To install Docker CE, you need the 64-bit version of one of these Ubuntu versions:
  • Cosmic 18.10
  • Bionic 18.04 (LTS)
  • Xenial 16.04 (LTS)
Docker CE is supported on x86_64 (or amd64), armhfarm64s390x (IBM Z), and ppc64le (IBM Power) architectures.

Uninstall old versions

Older versions of Docker were called dockerdocker.io , or docker-engine. If these are installed, uninstall them:
$ sudo apt-get remove docker docker-engine docker.io containerd runc 
It’s OK if apt-get reports that none of these packages are installed.
The contents of /var/lib/docker/, including images, containers, volumes, and networks, are preserved. The Docker CE package is now called docker-ce.

Supported storage drivers

Docker CE on Ubuntu supports overlay2aufs and btrfs storage drivers.

Note: In Docker Engine - Enterprise, btrfs is only supported on SLES. See the documentation on btrfs for more details.
For new installations on version 4 and higher of the Linux kernel, overlay2 is supported and preferred over aufs. Docker CE uses the overlay2 storage driver by default. If you need to use aufs instead, you need to configure it manually. See aufs

Install Docker CE


Install from a package

You can download the .deb file for your release and install it manually. You need to download a new file each time you want to upgrade Docker.

1. Go to https://download.docker.com/linux/ubuntu/dists/, choose your Ubuntu version, browse to pool/stable/, choose amd64, armhf, arm64, ppc64el, or s390x, and download the .deb file for the Docker CE version you want to install.

2. Install Docker CE, changing the path below to the path where you downloaded the Docker package.
$ sudo dpkg -i /path/to/package.deb

The Docker daemon starts automatically. For example:



3. Verify that Docker CE 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.


Docker CE is installed and running. The docker group is created but no users are added to it. You need to use sudo to run Docker commands. Continue to Post-installation steps for Linux to allow non-privileged users to run Docker commands and for other optional configuration steps.

Upgrade Docker CE

To upgrade Docker CE, download the newer package file and repeat the installation procedure, pointing to the new file.

Post-installation steps

This section contains optional procedures for configuring Linux hosts to work better with Docker.


Manage Docker as a non-root user

The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using  sudo. The Docker daemon always runs as the root user.

If you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of thedocker group.

WarningThe docker group grants privileges equivalent to the root user. For details on how this impacts security in your system, see Docker Daemon Attack Surface.
To create the docker group and add your user:
1. Create the docker group.
$ sudo groupadd docker
2. Add your user to the docker group.
$ sudo usermod -aG docker $USER
For example, my user name is 
super so command is:
$ sudo usermod -aG docker super
3. Log out and log back in so that your group membership is re-evaluated.
If testing on a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.
On a desktop Linux environment such as X Windows, log out of your session completely and then log back in.
4. Verify that you can run docker commands without 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.

If you initially ran Docker CLI commands using sudo before adding your user to the docker group, you may see the following error, which indicates that your ~/.docker/ directory was created with incorrect permissions due to the sudo commands.
WARNING: Error loading config file: /home/user/.docker/config.json -
stat /home/user/.docker/config.json: permission denied
To fix this problem, either remove the ~/.docker/ directory (it is recreated automatically, but any custom settings are lost), or change its ownership and permissions using the following commands:
$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
$ sudo chmod g+rwx "$HOME/.docker" -R

Configure Docker to start on boot

Most current Linux distributions (RHEL, CentOS, Fedora, Ubuntu 16.04 and higher) use systemd to manage which services start when the system boots. Ubuntu 14.10 and below use upstart.
systemd
$ sudo systemctl enable docker
To disable this behavior, use disable instead.
$ sudo systemctl disable docker
If you need to add an HTTP Proxy, set a different directory or partition for the Docker runtime files, or make other customizations, seecustomize your systemd Docker daemon options.
upstart
Docker is automatically configured to start on boot using upstart. To disable this behavior, use the following command:
$ echo manual | sudo tee /etc/init/docker.override

chkconfig

$ sudo chkconfig docker on

Uninstall Docker CE

1. Uninstall the Docker CE package:
$ sudo apt-get purge docker-ce
2. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:

$ sudo rm -rf /var/lib/docker

You must delete any edited configuration files manually.

Good Luck!