Mint

How to install Docker and run Docker containers on Linux Mint 18/18.1

Docker is an open source project supported by a commercial entity of the same name that makes it super-easy to run an application process inside a relatively isolated environment called a container. Unlike a virtual machine (VM), which has its own kernel, a container is dependent on the host operating system’s kernel.

As a result, it’s much lighter and boots up much faster. It’s the simplest tool that puts enterprise-class application deployment and management capabilities right on your desktop (laptop). By default, Docker containers are run using application images hosted on Docker Hub.

In this article, we’ll go through the process of installing and using it to run containers on Linux Mint 18 and 18.1. Linux Mint 18.1 is set to be released very soon, but these instruction will work on it too.

Enable Official Docker Repository on Linux Mint 18/18.1

The official repository of Linux Mint 18 and also 18.1, which are both based on Ubuntu 16.04, contain a slightly outdated edition of the Docker package than is available on Ubuntu 16.10 or Fedora 25 (see How to install Docker and run Docker containers on Fedora 25). For example, if you attempt to install it (Docker) from the official Linux Mint repository, you will likely be installing Docker 1.12.1, as opposed to the very latest (at the time of this writing) – Docker 1.12.3.

So to make it such that the latest and greatest version of Docker will always be available on your system, it’s better to enable the official Docker repository. To get that done, run the following commands:

Install Docker Prerequisites on Linux Mint 18/18.1

To install and successfully run Docker containers on Linux Mint 18 and 18.1, even after kernel upgrades, use the following command to install a few required packages:

Install Docker on Linux Mint 18/18.1

Now that all is set, you may install Docker using the next command, which will not only install it, but also start the daemon and enable it, so that it will always start at boot.

Run/Manage Docker Containers on Linux Mint 18/18.1

The Docker daemon is up and running, so you may now run your first container using the following command

As stated earlier, images used to run Docker containers are, by default, hosted on Docker Hub. With hundreds, perhaps thousands of images available, how do you find an image with which to run a container? By using Docker’s search command. For example, let’s see if Linux Mint has an image hosted on Docker Hub:

Related Post:  Provision Dockerized hosts on Vultr with Docker Machine from Linux Mint 18.1, Ubuntu 16.04

When searching for an image to run a container, always use one with OK in the OFFICIAL column. That indicates it came from the project itself, not from any random person. In the output above, for example, there’s no official image for Linux Mint, but there’s one for Ubuntu and Oracle Linux. So let’s try and run a container using the official Ubuntu image:

The above command will download the Ubuntu image, run the container, keep it running, and give you interactive tty access inside it, with the Bash shell. You’ll notice that your command prompt has changed to something like root@131a58505d2d:/#, where the string after the @ sign is the unique id of the container. So your host machine is running Linux Mint 18, but you’re now operating from inside an Ubuntu container.

With command line access inside the container, you can do anything you want, like just exit the container, or do somethings more interesting, like update the package database, upgrade the system, and install any software you feel like installing. For now, you may exit the container by typing exit. In a future article, we’ll go into details of how to install applications inside a container, commit the changes, and push the new image derived from that to Docker Hub.

Let’s end this by running another container using the official Nginx image. By default, running the Nginx container will expose its ports 80 (http) and 443 (https). What this command does is map port 80 on the host machine to the equivalent port inside the container.

Related Post:  How to install Go on Linux Mint 18 18.1 and Ubuntu 16.04 16.10

Mapping the port in that fashion makes it possible to access the default Nginx page by pointing your browser to the host machine’s IP address. If you did that, you should see the default Nginx page, and if you ran the command without the -d option, you should see some output indicating that the page has been accessed. Depending on the host machine’s resources, you can run as many containers as you want – at the same time.

Use the next set of commands to list the containers running on the host machine, stop a running container and remove a stopped container:

Clean Up After Yourself

Whenever you run a container, the Docker client has to download an image from (by default) Docker Hub. The images are stored on your computer, and will remain there even after you’ve stopped and removed the container. With time, those images can take up a significant chunk of your computer’s storage space.

So a good habit to adopt is to delete those images you’ll not be using anytime soon. To list the images stored on your computer, type:

Don’t think you’ll be needing an image anytime soon? Delete it:

Running individual Docker containers like you just read in this article is fun, but that’s just the beginning. Docker has other features, like the Swarm Mode, which makes it easy to orchestrate a cluster of Docker containers across a cluster of servers running Docker. The next article will show how to install Docker Machine on Linux Mint 18/18.1. Docker Machine is used to provision servers running Docker. More on Docker here.

Docker on Linux Mint 18

Subscribe to LinuxBSDos.com

Subscribe to receive the latest articles in your Inbox

Trust me, you'll not be spammed...

Please share:

We Recommend These Vendors and Free Offers

Launch an SSD VPS in Europe, USA, Asia & Australia on Vultr's KVM-based Cloud platform starting at $5:00/month (15 GB SSD, 768 MB of RAM).

Deploy an SSD Cloud server in 55 seconds on DigitalOcean. Built for developers and starting at $5:00/month (20 GB SSD, 512 MB of RAM).

Want to become an expert ethical hacker and penetration tester? Request your free video training course of Online Penetration Testing and Ethical Hacking

Whether you're new to Linux or are a Linux guru, you can learn a lot more about the Linux kernel by requesting your free ebook of Linux Kernel In A Nutshell.


One Comment

  1. Hey,

    Thanks for the guide! One thing I found in my installation:

    sudo apt-add-repository \'deb https://apt.dockerproject.org/repo ubuntu-xenial main\' was not working for me as as it gave out this error when doing sudo apt update:

    Err:11 https://download.docker.com/linux/ubuntu serena Release 404 Not Found

    However, adding a trailing slash to the repo helped.

    sudo apt-add-repository \'deb https://apt.dockerproject.org/repo/ ubuntu-xenial main\'

Leave a Comment

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

*