Docker is an application that allows us to deploy programs that are run as containers. It was written in the popular Go programming language. This tutorial explains how to install Docker CE on Ubuntu 18.04 LTS.
Older versions of Docker were called
docker-engine. If these are installed in your machine, uninstall them:
sudo apt-get remove docker docker-engine docker.io containerd runc
Let’s make sure that we are using a clean system. Update the apt package index and upgrade:
sudo apt-get update && sudo apt-get upgrade -y
Install packages to allow
apt to use a repository over HTTPS:
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Verify that you now have the key with the fingerprint
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 by searching for the last 8 characters of the fingerprint:
sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA] 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid [ unknown] Docker Release (CE deb) <firstname.lastname@example.org> sub rsa4096 2017-02-22 [S]
Use the following command to set up the stable repository:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update the apt package index:
sudo apt-get update
Install the latest version of Docker CE and containerd:
sudo apt-get install docker-ce docker-ce-cli containerd.io
The docker group is created but no users are added to it. You need to use
sudo to run Docker commands. Create a non-root user which will be added to the docker group:
adduser user usermod -aG docker user
Restart the Docker service:
systemctl restart docker
Run the Docker
hello-world container to ensure that the installation completed successfully:
docker run hello-world
Hello from Docker! This message shows that your installation appears to be working correctly.
Lastly, enable Docker to run when your system boots:
systemctl enable docker
Congratulations, you have successfully installed Docker. To further explore Docker, visit the official documentation to get started.