The Lazy Guide to Installing Docker

The step-by-step process in this tutorial also works for desktop Linux, because here I explain how to read the Docker installation docs from the official site — unlike articles on Medium and elsewhere.

For the installation, just follow the step-by-step from Docker Docs — trust me, you only need to copy and paste each step, and that’s just 2 steps in one menu and 1 more step in another. Here is how I do it when I have a new server and need to install Docker.

First, log in to the server — just run this in the terminal / command line

# Snippet
ssh <user>:<ip-public>
# Example
ssh supanadit@123.123.123.123
# Or if it has been integrated with a domain, simply
ssh john@example.com

Second, after logging in to the server via SSH, you can see the image below — taken from the Docker documentation — with Point 1 and 2 containing shell commands, and just run those two points. Notice the sidebar on the right: I’m on the Ubuntu tab. If you’re using another OS, simply pick that OS’s documentation.

What about step 3? Just skip it, because it’s wrong…. the Docker documentation assumes you’re using the root user.

Link: https://docs.docker.com/engine/install/ubuntu/

Summary Command
# 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 "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Only after you finish installing Docker can you move on to the documentation below.

Link: https://docs.docker.com/engine/install/linux-postinstall/

Summary Code
sudo usermod -aG docker $USER

Run only point No. 2, then run the command below to enable Docker and ContainerD SystemD services.

sudo systemctl enable --now docker.service
sudo systemctl enable --now containerd.service

After that there are two options: close your terminal and log in to the server again, or just restart the server.

How do I restart the server?

Just run the command below

sudo shutdown -r now
# Atau
sudo reboot

Once that’s done, you can test it by running docker ps -a — if there are no errors, Docker is properly installed on your server.

Short and sweet, see you in the next article… By the way, if you run into any issues, feel free to write them in the comments — I’ll be happy to help. The more problems I get, the more experience I gain 😁.

Leave a comment

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