1-4 Installing Docker Engine
Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called containers that have everything the software needs to run including libraries, system tools, code, and runtime.
To get started with Docker Engine on Ubuntu, make sure you meet the prerequisites, and then follow the installation steps.
OS Requirements
To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions:
- Ubuntu Oracular 24.10
- Ubuntu Noble 24.04 (LTS)
- Ubuntu Jammy 22.04 (LTS)
- Ubuntu Focal 20.04 (LTS)
Docker Engine for Ubuntu is compatible with x86_64 (or amd64), armhf, arm64, s390x, and ppc64le (ppc64el) architectures.
Step 1: Uninstall Old Versions
Before you can install Docker Engine, you need to uninstall any conflicting packages. Run the following command to uninstall all conflicting packages:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
If you have none of these packages installed, you may continue to the installation step.
Step 2: Set up Docker's apt
Repository.
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker apt
repository. Afterwards, you can install and update Docker from the repository.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
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 the 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 "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Step 3: Install the Docker packages.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
This will install all the required packages to use Docker.
Step 4: Verify the installation by running:
sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.
Step 5: Post-Installation
If you don't want to preface the docker
command with sudo
, create a Unix group called docker and add users to it.
First, create the docker
group.
sudo groupadd docker
Add your user to the docker
group.
sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated. You can also run the following command to activate the changes to groups:
newgrp docker
Verify that you can run docker
commands without sudo
.
docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.