(Last Updated On: November 8, 2018)

How to Install Docker CE on Ubuntu, Debian, Fedora, Arch, and CentOS guide is provided here. Note that older versions of docker ( docker and docker-engine), are no longer supported. At the moment, docker CE ( Community Edition) and docker EE ( Enterprise edition) are available.

Install Docker CE

Also check:

Install and Configure Docker Registry on CentOS 7

How to Setup Docker Private Registry on Ubuntu 18.04 / Ubuntu 16.04 with Letsencrypt SSL

What’s Docker?

Docker is a container runtime engine which allows you to package an application with all of its dependencies into a standardized unit for software development.

Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.

Why Docker?

Following are key things to note about docker:

  1. Docker containers are based on open standards allowing containers to run on all major Linux distributions and Microsoft operating systems with support for every infrastructure.
  2. Docker gives developers the freedom to define environments, and create and deploy apps faster and easier, and flexibility for IT ops to quickly respond to change.
  3. Containers isolate applications from each other and the underlying infrastructure while providing an added layer of protection for the application.
  4. Each virtual machine includes the application, the necessary binaries and libraries and an entire guest operating system – all of which may be tens of GBs in size.
  5. Containers include the application and all of its dependencies, but share the kernel with other containers. They run as an isolated process in userspace on the host operating system. They’re also not tied to any specific infrastructure – Docker containers run on any computer, on any infrastructure, and in any cloud.
  6. Docker gives you choice without complexity, from a laptop to a team, to private infrastructure and public cloud providers.

Installing Docker CE

Here we’ll cover installation of Docker CE on Ubuntu, Debian, Fedora, and CentOS and Arch Linux distributions.

Install Docker CE on Ubuntu

Uninstall Old version of Docker. Old versions of docker had the name docker or docker-engine. If you have it installed, first uninstall it.

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

The Docker CE package is now called docker-ce.

Update the apt package index:

$ sudo apt-get update

Install packages to allow apt to use a repository over HTTPS:

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

Add Docker’s official GPG key:

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

Add stable repository:

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

Install docker ce:

$ sudo apt-get update
$ sudo apt-get install docker-ce

If you would like to use Docker as a non-root user, you should now consider adding your user to the “docker” group with something like:

$ sudo usermod -aG docker your-user

Run the command below to see a version of docker installed.

$ docker version
docker version 
Client:
Version: 17.10.0-ce
API version: 1.33
Go version: go1.9.1
Git commit: f4ffd2511c
Built: Wed Oct 18 23:08:56 2017
OS/Arch: linux/amd64

Server:
Version: 17.10.0-ce
API version: 1.33 (minimum version 1.12)
Go version: go1.9.1
Git commit: f4ffd2511c
Built: Wed Oct 18 23:09:11 2017
OS/Arch: linux/amd64
Experimental: false

To get more details about docker, run:

$ docker info

Install Docker CE on Debian

Update the apt package index:

$ sudo apt-get update

Install packages to allow apt to use a repository over HTTPS:

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

Add Docker’s official GPG key:

$ curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -

Set up the stable repository:

$ sudo add-apt-repository \
 "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
 $(lsb_release -cs) \
 stable"

Install Docker:

$ sudo apt-get update
$ sudo apt-get install docker-ce

Uninstall Docker CE on Debian

If you would like to uninstall Docker CE, use the commands:

$ sudo apt-get purge docker-ce

Clean images, containers, and volumes:

$ sudo rm -rf /var/lib/docker

Install Docker CE on Fedora:

Uninstall Older versions of Docker:

$ sudo dnf remove docker \
docker-common \
docker-selinux \
docker-engine-selinux \
docker-engine

Configure Docker repository:

$ sudo dnf -y install dnf-plugins-core
$ sudo dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo

Install Docker CE:

$ sudo dnf install docker-ce

Start and enable docker service:

$ sudo systemctl start docker && systemctl enable docker

Install Docker CE on CentOS:

Uninstall old versions:

$ sudo yum remove docker \
   docker-common \
   docker-selinux \
   docker-engine

Install Prereqs:

$ sudo yum install -y yum-utils \
 device-mapper-persistent-data \
 lvm2

Setup stable repo:

$ sudo yum-config-manager \
 --add-repo \
 https://download.docker.com/linux/centos/docker-ce.repo

Install Docker CE:

$ sudo yum install docker-ce

If you get dependency errors, the run:

$ sudo yum install -y --setopt=obsoletes=0 docker-ce-17.03.1.ce-1.el7.centos \
docker-ce-selinux-17.03.1.ce-1.el7.centos

Start and enable docker service:

$ sudo systemctl start docker && sudo systemctl enable docker

Install Docker CE on Arch:

Install pacaur:

$ curl -s https://gist.githubusercontent.com/Tadly/0e65d30f279a34c33e9b/raw/pacaur_install.sh | bash

Install Docker CE using pacaur:

$ pacaur --needed --noconfirm --noedit -S docker

Confirm that it was successfully installed:

$ docker version
Client:
Version: 17.12.0-ce
API version: 1.33 (downgraded from 1.35)
Go version: go1.9.2
Git commit: 486a48d270
Built: Fri Dec 29 12:13:10 2017
OS/Arch: linux/amd64
Experimental: false

Server:
Engine:
Version: 17.10.0-ce
API version: 1.33 (minimum version 1.12)
Go version: go1.9.1
Git commit: f4ffd2511c
Built: Wed Oct 18 23:09:11 2017
OS/Arch: linux/amd64
Experimental: false

After installing Docker, you may be interested in:

Install Docker UI manager – Portainer

How to solve Error: Package: docker-ce-18.06.1.ce-3.el7.x86_64 (docker-ce-stable) Requires: container-selinux >= 2.9

How to Setup Docker Private Registry on Ubuntu 18.04 / Ubuntu 16.04 with Letsencrypt

Install and Configure Docker Registry on CentOS 7

Tags

How to get docker running on Ubuntu 16.04 and Ubuntu 17
Latest docker installation on Debian and Ubuntu
Install the latest docker on Kali Linux
Docker definitive installation for Debian derivatives
How to get started with docker on Ubuntu and Debian