Install docker engine on Pop!_OS 22.04

Introduction

This post contains my notes on installing docker engine on Pop!_OS following the guidance here: docker engine install on Ubuntu . Although the instructions are geared to Ubuntu, these should work with Pop!_OS just fine.

Uninstall old version

The guidance suggest that old, or conflicting, packages be removed using the command:

$ 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 are like me, this repeatedly states that the package "...is not installed, so not removed..." This might be different for you if you've previously attempted to install docker.

Install using the apt repository

The are a variety of ways to install docker engine, see here for the options. I will install by setting up the docker apt resposity, making future updates easy to do.

Add Docker's official GPG key

The first step is to update and install some dependencies (you might already have these installed):

$ sudo apt update
$ sudo apt install ca-certificates curl gnupg

Next, we add the GPG key using

$ 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

Next we add the repository to our sources using the key that we download above:

$ 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

There is no output after the command above...

Install docker

Finally, we can update and install the required packages. First, update:

$ sudo apt update

If you look carefully at the output from the update you should see a couple of docker repositories in the list of sources checked. Now, the install can be run using:

$ sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Verify the install

Assuming the install went without error (it did for me), we can run a test image called "hello-world". This runs a simple test image and exits with a little message. The results for me were:

$ sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
e6590344b1a5: Pull complete
Digest: sha256:d715f14f9eca81473d9112df50457893aa4d099adeb4729f679006bf5ea12407
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

Yay, looks like things are good to go! Note that the "docker run" command has to be run with sudo. If you want to avoid this, you can add your user to the docker group, as detailed here.