Install Docker Engine on Ubuntu
Installing Docker on Ubuntu 20.04
Update September 2025:
There is now a script provided by Docker.com to simplify the installation of Docker.
As with any script you download from the Internet, make sure you are aware of what the scipt does before running the script!
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh
You still need to run steps 8 and 9 below for the post-installation steps
- Update the
aptpackage index:
sudo apt update
- Uninstall old version(s):
sudo apt remove docker docker-engine docker.io containerd runc
- Set up the Docker apt repository:
sudo apt install ca-certificates curl gnupg lsb-release -y
- Add Docker's GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- Add the Docker repository:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Update the
aptpackage index:
sudo apt update
- Install the Docker engine:
sudo apt install docker-ce docker-ce-cli containerd.io -y
- Add the docker group:
sudo groupadd docker
- Add your username to the docker group:
sudo usermod -aG docker $USER
- After logging out, then back in, verify you can run
dockercommands withoutsudo:
docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:bfea6278a0a267fad2634554f4f0c6f31981eea41c553fdf5a83e95a41d40c38
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
References
Docker Docs - Install Docker Engine on Ubuntu https://docs.docker.com/engine/install/ubuntu/
Docker Docs - Install Docker Engine on Ubuntu - Install using the convenience script
https://docs.docker.com/engine/install/ubuntu/#install-from-a-package