1. Update APT:
sudo apt-get update
2. Install these packages first:
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
3. Add GPG keys:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
4. Then add 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
5. Update again:
sudo apt-get update
6. Install docker-ce, cli and containerd.io:
sudo apt-get install docker-ce docker-ce-cli containerd.io
must work - be sure to execute all commands as root or with sudo.
You can also use their script to automate everything:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo ./get-docker.sh