Using APT
-
Update the package index
sudo apt update
-
Install required packages
sudo apt-get install ca-certificates curl
-
Make Docker’s official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
-
Download Docker GPG key
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
-
Set key permissions
sudo chmod a+r /etc/apt/keyrings/docker.asc
-
Set up the stable repository
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
-
Update the package again
sudo apt-get update
-
Install the latest version
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
-
Verify the installation
sudo docker run hello-world
This command downloads a test image and runs it in a container. If Docker is installed correctly, you will see a message saying "Hello from Docker!".
Docker has been successfully installed and is ready to use!
From a Package
- Go to https://download.docker.com/linux/ubuntu/dists/
- Select your Ubuntu version in the list.
- you can find out the Ubuntu version with this command
lsb_release -c
- Go to pool/stable/ and select the applicable architecture (amd64, armhf, arm64, or s390x).
- You can find out the architecture with this command
dpkg --print-architecture
- Download the following deb files for the Docker Engine, CLI, containerd, and Docker Compose packages:
- containerd.io_<version>_<arch>.deb
- docker-ce_<version>_<arch>.deb
- docker-ce-cli_<version>_<arch>.deb
- docker-buildx-plugin_<version>_<arch>.deb
- docker-compose-plugin_<version>_<arch>.deb
- Install the .deb packages. Update the paths in the following example to where you downloaded the Docker packages.
The Docker daemon starts automatically.sudo dpkg -i ./containerd.io_<version>_<arch>.deb \ ./docker-ce_<version>_<arch>.deb \ ./docker-ce-cli_<version>_<arch>.deb \ ./docker-buildx-plugin_<version>_<arch>.deb \ ./docker-compose-plugin_<version>_<arch>.deb
- Verify the installation
This command downloads a test image and runs it in a container. If Docker is installed correctly, you will see a message saying "Hello from Docker!".sudo service docker start sudo docker run hello-world
- Start Docker
Docker has been successfully installed and is ready to use!sudo systemctl start docker