Docker is now available on the official Docker package registry as docker-ce. But before we install docker-ce, we should remove older versions of Docker that may be on our machine:
$ sudo apt remove -y docker docker-engine docker.io
Now, we can install docker-ce:
$ sudo apt install -y docker-ce
Verify if the installation is working by running sudo docker version. You should get an output similar to the following:
$ sudo docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:17:38 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:15:45 2018
OS/Arch: linux/amd64
Experimental: false