
Before installing Docker Engine on a new Ubuntu host machine, you need to set up the Dockerapt
repository. Once the repository is configured, you can install and update Docker directly from it.
1.Set up Docker'sapt
repository
Follow these steps to configure the repository:
# Update package index and install prerequisites:sudoapt-get updatesudoapt-getinstall-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:sudocurl-fsSL https://download.docker.com/linux/ubuntu/gpg-o /etc/apt/keyrings/docker.ascsudo chmoda+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:sudoapt-get update
2.Install Docker packages
Install the latest version of Docker Engine and its components:
sudoapt-getinstall-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:
sudosystemctl status containerdsudosystemctl status docker
If either service is inactive, start them using:
sudosystemctl start containerdsudosystemctl start docker
4.Verify the installation
Run thehello-world
image to confirm Docker is working correctly:
sudodocker run hello-world
This command downloads a test image, runs it in a container, and prints a confirmation message.
5.Run Docker withoutsudo
To avoid usingsudo
with every Docker command, add your user to the Docker group:
sudousermod-aG docker$USERnewgrp docker
6.Final verification
Run thehello-world
image again, this time withoutsudo
:
docker run hello-world
If successful, you have installed and configured Docker Engine on your Ubuntu machine.
References
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse