How to install Docker on Linux Mint 21 Vanessa

How to install Docker on Linux Mint 21 Vanessa

Same steps for Ubuntu 22.04 LTS (Jammy Jellyfish)

Everyone is using Docker nowadays. Main reasons include ease of development and rapid deployment. Why bother downloading and installing the required dependencies to start using your preferred programming language when you can do that out of the box with a few commands in your terminal. Thanks to Docker, you can just run a simple command and start using your software instantly. You can also package (a.k.a create an image of) your application with the required dependencies, easily share it, and run it anywhere. It is no wonder that Docker has become a crucial ingredient of a developer's toolset.


Installing Docker

Let's first update the apt package index and install some required packages:

sudo apt update

sudo apt install ca-certificates curl gnupg

We need to add Docker’s GPG key

 sudo mkdir -p /etc/apt/keyrings

 curl -fsSL | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Then use this command to add the repository to sources.list.d

# Please note that we are using Ubuntu Jammy's repo
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] jammy stable" \
| sudo tee /etc/apt/sources.list.d/docker.list

Now we can install Docker Engine

sudo apt update
#  Install the latest version of Docker Engine, containerd, and Docker Compose
sudo apt install docker-ce docker-ce-cli docker-compose-plugin

Using Docker as a non-root user

To avoid prefacing docker commands with sudo we will create the docker group and add the current user to it.

sudo groupadd docker
sudo usermod -aG docker $USER

All you have to do now is to log out and log back in again. Then, verify that you can run docker commands without sudo by running docker run hello-world