×

How to Install Docker on Linux Mint 21 – LinuxWays

How to Install Docker on Linux Mint 21 – LinuxWays


Docker is a well-known containerization forum that enables users to containerize or package their desired application along with all dependencies. It helps users to easily deploy/build and run their applications seamlessly across various environments. If you are working on the Linux Mint system and want to package your required applications into a container, you can install Docker. It will permit you to build and handle containers for your necessary applications.

This guide will illustrate all the possible ways to install Docker on your Linux Mint system.

Quick Outline

How to Install Docker on Linux Mint 21

In Linux Mint, you can use the following methods to install Docker on your system:

Method 1: Default Linux Mint Repository

The Official Linux Mint repository contains a list of various Docker packages that can be installed via the “apt” command. The easiest way to install Docker is using the default Linux Mint repository but it does not install its latest version.

To install Docker on Linux Mint from the default Linux Mint repository, you can use the provided steps:

Step 1: Update System Packages

First, update the Linux Mint packages list before installing Docker using the given command:

sudo apt update;sudo apt upgrade -y

Subsequently, all the system’s repository packages will be updated:

Step 2: Install Docker on Linux Mint

Now, utilize the provided command to install Docker from Linux Mint’s APT repository:

sudo apt install docker.io -y

Moreover, if you want to install Docker with all the dependencies and packages from the APT repository, execute the following command:

sudo apt install docker* -y

By doing so, all the Docker-related packages will be installed:

Step 3: Verification

Finally, check the Docker’s version to verify that the Docker has been installed on the system:

The below output indicates that the older version of Docker has been successfully installed:

Method 2: Official Docker Repository

If you want to install the latest version of Docker, add the official Docker repository to your Linux Mint system. This method will not only install Docker’s latest version but also update it automatically using the package manager on your system whenever the new version is released (available).

Here are the steps:

Step 1: Update and Upgrade System Repository

First, update and upgrade the system’s packages:

sudo apt update;sudo apt upgrade

Step 2: Install Necessary Dependencies

Next, install the desired dependencies for Docker’s installation on Linux Mint:

sudo apt install gnupg ca-certificates apt-transport-https curl

Here:

  • curl” is utilized to make/create HTTP requests on the internet.
  • gnupg2” is a tool for encryption and secure communication.
  • apt-transport-https” allows APT repositories to use HTTPS protocol for secure package downloads.
  • ca-certificates” is utilized for a secure connection.

Step 3: Import GPG Key for Docker

Now, import the GPG key using the given command to ensure the integrity of Docker packages on Linux Mint:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg –dearmor -o /etc/apt/keyrings/docker.gpg

Step 4: Add Official Docker Repository in Linux Mint

Then, add/import the Docker’s official repository to the system:

echo “deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo “$UBUNTU_CODENAME”) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 5: Update System’s Package List

After that, update the system’s repository to successfully add the Docker repository to the system:

Upon doing so, the repository’s package list has been updated:

Step 6: Install Required Packages of Docker

Now, install the latest version of the desired Docker packages using the “sudo apt install” command and specify the required package names that you want to install. For instance, we are installing the following Docker packages on Linux Mint:

sudo apt install containerd.io docker-ce docker-ce-cli -y

Here:

  • containerd.io” is the container runtime that handles the container’s lifecycle.
  • docker-ce” is the Docker engine, i.e., ce=community edition.
  • docker-ce-cli” is the Docker command-line interface to interact/communicate with Docker Daemon.

Step 7: Verification

To verify whether Docker’s latest version has been installed or not, write out the given command:

As you can see, the latest version of Docker has been successfully installed on Linux Mint:

Method 3: Deb File

Another way to install Docker on Linux Mint is by downloading its deb package files from its official website. This method installs Docker’s latest version, but you will not get upgraded automatically when the new release is introduced. To get the new Docker version, download the new deb package files and install them on your system via deb files:

Step 1: Download Docker Deb Files on Linux Mint

First, download the required latest deb files from the official Docker website by clicking on them. Here, we are downloading the latest version of the “containerd.io”, “docker-ce”, and “docker-ce-cli” deb files:

Step 2: Install Docker on Linux Mint

Then, launch the terminal and redirect to the “Downloads” folder where the deb package files are downloaded:

It can be observed that the “Downloads” directory contains the Docker’s deb files:

Now, use the “sudo apt install” command with the deb package file names to install Docker on your system:

sudo apt install ./containerd.io_1.6.26-1_amd64.deb ./docker-ce_24.0.7-1~ubuntu.22.04~jammy_amd64.deb ./docker-ce-cli_24.0.7-1~ubuntu.22.04~jammy_amd64.deb -y

Step 3: Verification

Finally, check the Docker’s version to ensure that it has been installed on your Linux Mint system:

The below output indicates that the latest version of Docker has been installed successfully:

Method 4: Shell Script

Docker also offers a shell script that can be used to install Docker on Linux Mint. It is the easiest and quickest approach for installing Docker’s latest version on your systems. You can try out the given steps to install Docker via convenience script on the Linux Mint system:

Step 1: Download the Convenience Script on the System

First, use the “curl” command to download the Docker’s convenience script on your system with the name “install-docker.sh”:

curl -fsSL https://get.docker.com -o install-docker.sh

Step 2: Install Docker on Linux Mint

Then, run the “install-docker.sh” script file using the provided command to install and set up Docker on Linux Mint:

sudo sh install-docker.sh

According to the below output, the convenience script has successfully installed the latest version of Docker:

Method 5: Snap Store

The Snap store contains the Docker package that can be installed easily using the Snap package manager. However, this method does not install the latest (updated) version of Docker.

To install Docker from the Snap Store, try out the below-mentioned steps:

Step 1: Enable Snap on Linux Mint

In the Linux Mint systems, Snap support is not enabled by default and because of that, users cannot download the package or app from the Snap Store. So, if you want to install an application from the Snap Store, enable the Snap support first by removing the “nosnap.pref” file from the APT directory using the given command:

sudo rm /etc/apt/preferences.d/nosnap.pref

Then, write out the below-listed command to update the APT cache:

Next, install the “snapd” package on your Linux Mint system using the following command:

After that, utilize the provided command to enable the Snap Demon on Linux Mint to install the Snap applications:

sudo systemctl enable snapd

By doing so, Snap support has been enabled, allowing you to install the desired applications or packages from the Snap Store.

Step 2: Install Docker

Now, install Docker from the Snap Store on your Linux Mint system via the below-listed command:

As you can see, the older version of Docker has been installed from the Snap Store:

How to Use Docker as a Regular User on Linux Mint 21

When Docker is installed on Linux systems, the Docker Daemon runs with the root (sudo) privileges. It indicates that you have to run the Docker commands with the root rights. When you try to run Docker commands without “sudo”, it gives an error as seen below:

To resolve this issue and run Docker commands without sudo rights, follow the provided steps:

Step 1: Make Docker Group

First, utilize the “sudo groupadd” command and specify the group name for Docker to make its group. Here, we have specified “docker” as the group name:

Step 2: Add Current User to Docker Group

Next, add the current user (or any other user) to the docker group through the following command. Here, we are using the “usermod” command to modify the existing user and appending it to the “docker” group via the “-aG” flags:

sudo usermod -aG docker $USER

Step 3: Apply Changes

Then, run the below-listed command to refresh the current terminal sessions and apply the changes:

Step 4: Verification

To verify whether we can use Docker as regular users or not, execute the following command:

As you can see, the Docker commands are now successfully running without “sudo”. This indicates that now Docker can be used as a regular user on this system:

How to Uninstall/Remove Docker From Linux Mint 21

There are different possible ways to uninstall or remove Docker from your Linux Mint system. You can choose the specific removal method and remove Docker according to the installation method that you have used to install Docker.

If Installed Via Linux Mint/Docker Repository or Shell Script

If you have installed Docker from the default Linux Mint repository, the official Docker repository, or via the convenience script, use the following command to remove it from your system:

sudo apt autoremove docker* –purge -y

You should also remove the Docker repository from your system that you have added at the time of installation using the below-given command:

sudo rm /etc/apt/sources.list.d/docker.list

Similarly, remove the GPG key that was imported into your system through the below-given command:

sudo rm /etc/apt/keyrings/docker.gpg

If Installed Via Deb Files

If you have installed Docker via the deb packages files, utilize the provided command to remove it from your system:

sudo apt remove containerd.io docker-ce docker-ce-cli -y

If Installed Via Snap Method

If the Docker is installed from the Snap Store, remove/uninstall it as:

That was all about installing and uninstalling Docker on Linux Mint.

Note: Check out the official documentation of Docker for more information.

Conclusion

Docker is a containerized tool that is used to isolate applications that can be run in different environments. You can install Docker on Linux Mint through the default APT repository, official Docker repository, deb files, convenience script, or from Snap Store.

Among these methods, the default APT Linux repository method and convenience script method are the easiest way to install Docker. However, if you want to get Docker’s latest version on your system, you can use the official Docker repository or Deb file methods. This guide has explained all these potential ways to install as well as remove/uninstall Docker on Linux Mint. You can follow any of these methods to install and use Docker on the Linux Mint system.



Source link