Installing Docker and Docker Compose

The instructions that follow are for Debian which provides a dependency-resolving package manager, “apt-get” (now shortened to “apt”). Prior to that, installing software in Linux could require manually hunting down many different libraries and other dependencies before the software would actually work. Detailed instructions for Debian and other installations can be found in the Docker Documentation here.

For the sake of simplicity, I’ve included the steps for installing Docker Compose onto Debian as well as post-installation steps below. Note: I hardcoded the architecture here for Intel and AMD due to some issues using the official Docker guidance. If you’re using a Raspberry PI, Apple, or ARM-based systems you’ll want to change arch=amd64 to arch=arm64.

# 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/debian/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=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Once that’s complete, we can install the necessary packages.

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

So far, so good. However, we don’t want to have to run docker with sudo. To run it under your own user account we’ll need to take a few other steps.

Create a docker group:

sudo groupadd docker

Add your own user account to that group, you should be already logged in as that user. As a reminder, avoid logging in as the root account.

sudo usermod -aG docker $USER

After all this you’ll need to log out and back in to have the authorization changes take affect.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top