DEV Community

David Sánchez
David Sánchez

Posted on • Updated on

Install Docker Community Edition in Linux Mint

Docker is a popular software package that makes easier to create, deploy and run multiple applications using containers. By using containers, developers may be assured that their code will run on any other machine that may not have the same packages or configuration as the one used to create the project originally.

There are two Docker versions in existence: Docker CE (Community Edition) and Docker EE (Enterprise Edition). Docker CE is free and it's the one that we'll see how to install in this tutorial.

System Requirements

  • Linux Mint
  • A user account that has superuser privileges

What I'll use

  • Terminal: I'm using terminator as my Terminal Emulator. It's not going to be visible in the tutorial but 🤷
  • Linux Mint: I'm using Linux Mint 19.3 (Tricia) as my distribution.

Install Docker

These instructions are very similar to the ones posted in Docker's Documentation, there are going to be some differences specific to Linux Mint installation.

  • Step 1: Install dependencies to use a repository over HTTPS
  • Step 2: Add the Docker's official GPG key
  • Step 3: Set up the Docker repository
  • Step 4: Install Docker Engine
  • (Optional) Step 5: Allow non-privileged user to run Docker

Step 1: Install dependencies to use a repository over HTTPS

sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Enter fullscreen mode Exit fullscreen mode

Step 2: Add the Docker's official GPG key

When you add third-party repositories in Linux, you need to add their GPG key to ensure that the packages that are uploaded are valid and they can be installed in your system.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Enter fullscreen mode Exit fullscreen mode

Running this command will add the Docker's official GPG key to your system.

Step 3: Set up the Docker repository

This is the part I told you that will change a bit from the original instructions in Docker's website. Their instructions are only intended for Ubuntu and its derivatives, but if you follow them closely in Linux Mint, you'll end up having errors in the configuration.

This following line will tell us which is the Ubuntu version that our Linux Mint is built in top of:

grep "UBUNTU_CODENAME" /etc/os-release | awk -F '=' '{ print $2 }'
Enter fullscreen mode Exit fullscreen mode

As I'm using Linux Mint 19.3 (Tricia) it will display bionic as the output. This line will then be used to add the Docker repository in your system:

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(grep "UBUNTU_CODENAME" /etc/os-release | awk -F '=' '{ print $2 }') \
   stable"
Enter fullscreen mode Exit fullscreen mode

Step 4: Install Docker Engine

After this step is successfully executed, we can now install the Docker Engine by running a simple apt-get install command:

Note: I'm adding an apt-get update command here to make sure that we have the latest changes in the repositories. Usually, the previous step should automatically do it, but I want to be sure that they're up to date.

sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io
Enter fullscreen mode Exit fullscreen mode

(Optional) Step 5: Allow a non-privileged user to run Docker

If you try to run Docker with your normal user, you'll run into an error because Docker cannot be run by non-privileged users. This step adds your user to the docker group in your system and after rebooting your computer you'll be able to run Docker without sudo.

sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode

That's it, you should have Docker running correctly in your computer. If you're struggling with any step or just want to know a bit more about what does any of these commands do, just leave me a comment and I'll be more than happy to help you!

This is my first post in Dev.to and I'll be very grateful if you leave me any feedback about this post in the comments ❤️.

Latest comments (1)

Collapse
 
vidbaz profile image
vidbaz

Good Stuff, thanks bro