Install Docker on Ubuntu
Before installing Docker Engine on a new Ubuntu host machine, you need to set up the Docker apt repository. Once the repository is configured, you can install and update Docker directly from it. 1. Set up Docker's apt repository Follow these steps to configure the repository: # Update package index and install prerequisites: sudo apt-get update sudo apt-get install -y ca-certificates curl # Create a directory for Docker's GPG key: sudo install -m 0755 -d /etc/apt/keyrings # Download Docker's official GPG key: sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc # Add Docker's repository to Apt sources: 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 index again: sudo apt-get update 2. Install Docker packages Install the latest version of Docker Engine and its components: sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin 3. Check Docker and containerd status Verify that Docker and containerd services are running: sudo systemctl status containerd sudo systemctl status docker If either service is inactive, start them using: sudo systemctl start containerd sudo systemctl start docker 4. Verify the installation Run the hello-world image to confirm Docker is working correctly: sudo docker run hello-world This command downloads a test image, runs it in a container, and prints a confirmation message. 5. Run Docker without sudo To avoid using sudo with every Docker command, add your user to the Docker group: sudo usermod -aG docker $USER newgrp docker 6. Final verification Run the hello-world image again, this time without sudo: docker run hello-world If successful, you have installed and configured Docker Engine on your Ubuntu machine. References Docker Documentation Docker Installation Challenge

Before installing Docker Engine on a new Ubuntu host machine, you need to set up the Docker apt
repository. Once the repository is configured, you can install and update Docker directly from it.
1. Set up Docker's apt
repository
Follow these steps to configure the repository:
# Update package index and install prerequisites:
sudo apt-get update
sudo apt-get install -y ca-certificates curl
# Create a directory for Docker's GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
# Download Docker's official GPG key:
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add Docker's repository to Apt sources:
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 index again:
sudo apt-get update
2. Install Docker packages
Install the latest version of Docker Engine and its components:
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
3. Check Docker and containerd status
Verify that Docker and containerd services are running:
sudo systemctl status containerd
sudo systemctl status docker
If either service is inactive, start them using:
sudo systemctl start containerd
sudo systemctl start docker
4. Verify the installation
Run the hello-world
image to confirm Docker is working correctly:
sudo docker run hello-world
This command downloads a test image, runs it in a container, and prints a confirmation message.
5. Run Docker without sudo
To avoid using sudo
with every Docker command, add your user to the Docker group:
sudo usermod -aG docker $USER
newgrp docker
6. Final verification
Run the hello-world
image again, this time without sudo
:
docker run hello-world
If successful, you have installed and configured Docker Engine on your Ubuntu machine.