These instructions work on Ubuntu versions 20.10 (Groovy), 20.04 (Focal), 18.04 (Bionic) and 16.04 (Xenial).
If you're using an Ubuntu laptop or desktop, you can press Ctrl + Alt + T
on your keyboard to open a new terminal window. If you're using a remote Ubuntu server, you can connect using SSH to open a new terminal session.
Download Docker's Apt repo key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Verify the fingerprint of the key you just downloaded by running the command below, and making sure the output matches the output shown here.
$ 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)sub rsa4096 2017-02-22 [S]
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt update -y $ sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose
Run a Docker command to test that the installation worked:
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
In the previous step, you had to use sudo
in front of the docker
command. To get rid of this requirement, first add the current user to the docker
user group:
$ sudo groupadd docker $ sudo gpasswd -a $USER docker
Then exit the current terminal session:
$ exit
The next time you login, you will be able to run Docker commands without sudo
.
You are now ready to use Docker on your machine.