Docker is available through their own repository, which you must first enable for your package management system.
Follow these steps to get it safely installed:
- Install prerequisite packages
sudo apt-get update && sudo apt-get install ca-certificates curl gnupg
- Add Docker's GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
- Setup the repository
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Install the engine and other goodies
sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
You can verify the installation by issuing the following command:
sudo docker run hello-world
The instructions were copied from the following website, that has more details and other relevant information: https://docs.docker.com/engine/install/ubuntu/