Objective
Install Docker Engine from the official apt repository on a fresh
Ubuntu 24.04 LTS host. Verify the install end-to-end. Pin the
major version so subsequent apt upgrade calls do not surprise
you.
Requirements
- Ubuntu 24.04 LTS (or 22.04 LTS) host, freshly installed.
- sudo access.
- Outbound HTTPS to
download.docker.com. - A non-root user you can add to the
dockergroup, or sudo for everydockerinvocation.
Tasks
Task 1: Add Docker’s official 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
Task 2: Add 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
sudo apt-get update
Task 3: Install pinned version
# List available versions
apt-cache madison docker-ce | head -5
# Install a specific version (example: 28.1.1)
sudo apt-get install -y \
docker-ce=5:28.1.1-1~ubuntu.24.04~noble \
docker-ce-cli=5:28.1.1-1~ubuntu.24.04~noble \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
Task 4: Pin the major version
sudo apt-mark hold docker-ce docker-ce-cli
Task 5: Enable and start the daemon
sudo systemctl enable --now docker
sudo systemctl status docker
Task 6: Verify
docker version
docker info
sudo docker run --rm hello-world
Task 7: Non-root user
sudo usermod -aG docker $USER
# log out and back in
docker ps
Expected outcome
docker versionshows Server Version 28.x.docker infolists the storage driver, cgroup driver, and kernel version.hello-worldprints its standard success message.- The user can run
docker pswithout sudo.
Cleanup
Nothing to clean up. The hello-world container is --rm and
exits immediately.