Docker on Linux Mint 18

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:

# First import the GPG key

sudo apt-key adv --keyserver hkp:// \
      --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

# Next, point the package manager to the official Docker repository

sudo apt-add-repository 'deb ubuntu-xenial main'

# Update the package database

sudo apt update

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:

# Installing both packages will eliminate an unmet dependencies error when you try to install the 
# linux-image-extra-virtual by itself

sudo apt install linux-image-generic linux-image-extra-virtual

# Reboot the system so it would be running on the newly installed kernel image

sudo reboot


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.

# Install Docker

sudo apt install docker-engine


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

# Run a Docker container
# This container is just a test container, and it will run and exit

sudo docker run hello-world


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:

# How to search for Docker images

sudo docker search "linux mint"

# The output should be of this sort

NAME                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ubuntu                               Ubuntu is a Debian-based Linux operating s...   5185      [OK]       
oraclelinux                          Oracle Linux is an open-source operating s...   262       [OK]       
kalilinux/kali-linux-docker          Kali Linux Rolling Distribution Base Image      245                  [OK]
linuxserver/plex                     A Plex Media Server container, brought to ...   191                  [OK]
linuxserver/couchpotato              A CouchPotato container, brought to you by...   142                  [OK]
linuxserver/sonarr                   A Sonarr container, brought to you by Linu...   136                  [OK]
linuxserver/nzbget                   An Nzbget container, brought to you by Lin...   63                   [OK]
amazonlinux                          Amazon Linux is an execution environment f...   43        [OK]       
thewtex/cross-compiler-linux-armv6   Linux ARMv6 cross compiler toolchain for t...   7                    [OK]
thewtex/cross-compiler-linux-armv7   Linux ARMv7 cross compiler toolchain            4                    [OK]
condaforge/linux-anvil               The image used to build x86_64 conda distr...   2                    [OK]
jasonchaffee/kali-linux              Kali Linux Docker Container with the kali-...   2                    [OK]


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:

# Run a Docker container using the official Ubuntu image

sudo docker run -it ubuntu bash


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.

Related Post:  Dual-boot Linux Mint 17.1, Windows 7 on a PC with UEFI firmware

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.

# Run a Docker container using the official Nginx image

sudo docker run -p 80:80 nginx
# Alternatively, you can force the container to detach by running this command
sudo docker run -d -p 80:80 nginx


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.

Related Post:  Linux Mint 13 MATE/Cinnamon preview

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

# List all containers, running or not
sudo docker ps -a

# The output of the above commands takes this form
# CONTAINER ID      IMAGE        COMMAND              STATUS                PORTS                   NAMES
# 260c12455185        redis   ""  Up 14 seconds          6379/tcp                      jolly_ride
# c43c9f709786        nginx   "nginx -g 'daemon off"  Up 2 minutes>80/tcp, 443/tcp   desperate_ritchie
# 0febde3715a0        ubuntu       "bash"           Exited (0) 5 minutes ago                           infallible_lalande
# 0e5e4b38037a        hello-world    "/hello"          Exited (0) 2 hours ago                             grave_jones

# List only running containers

sudo docker ps

# Remove a stopped container. Specify the container's id or name when removing it
# In this case, we remove the container using its name

sudo docker rm grave_jones

# To remove a running container, first stop it using its name or id
# In this case, we stop it using its id

sudo docker stop 260c12455185

# Then remove it

sudo docker rm 260c12455185

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:

# Listing Docker images
sudo docker images

# Output of above command
# REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
# redis               latest              1c2ac2024e4b        6 days ago          182.9 MB
# ubuntu              latest              4ca3a192ff2a        13 days ago         128.2 MB
# nginx               latest              abf312888d13        2 weeks ago         181.5 MB
# hello-world         latest              c54a2cc56cbb        5 months ago        1.848 kB

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

# Delete a Docker image using its name
sudo docker rmi hello-world

# And in this case, using it id

sudo docker rmi 1c2ac2024e4b

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


Share on facebook
Share on twitter
Share on pinterest
Share on linkedin

Hola! Did you notice that no longer runs network ads?  Yep, no more ads from the usual suspects that track you across the Internet.  But since  I still need to pay to keep the site running, feel free to make a small donation by PayPal.

Subscribe for updates. Trust me, no spam!

Mailchimp Signup Form

Sponsored links

1. Attend Algorithm Conference, a top AI and ML event for 2020.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.

7 Responses

  1. I was having trouble running docker images, i unistalled it, then reinstalled using this commads and worked like a charm, thanks

  2. Hello,

    thank you for this article. You said:

    “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.”

    But I do not wish to have it always start at boot. What should I input and what commands should I use to start it manually?

  3. I followed these instructions to elliminate an error I was getting when trying to use docker from WSL.
    Ironically after Installing Linux Mint and following the instructions here I am getting the same error I was before.
    sudo docker run hello-world
    docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
    See ‘docker run –help’.

  4. Hey,

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

    `sudo apt-add-repository \’deb ubuntu-xenial main\’` was not working for me as as it gave out this error when doing `sudo apt update`:

    `Err:11 serena Release 404 Not Found`

    However, adding a trailing slash to the repo helped.

    `sudo apt-add-repository \’deb ubuntu-xenial main\’`

Leave a Reply

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

Get the latest

On social media
Via my newsletter
Mailchimp Signup Form

Sponsored links

1. Attend Algorithm Conference, a top AI and ML event for 2020.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.
Hacking, pentesting distributions

Linux Distributions for Hacking

Experts use these Linux distributions for hacking, digital forensics, and pentesting.


The authors of these books are confirmed to speak during

Algorithm Conference

T-minus AI

Author was the first chairperson of AI for the U.S. Air Force.

The case for killer robots

Author is the Director of the Center for Natural and Artificial Intelligence.

Why greatness cannot be planned

Author works on AI safety as a Senior Research Scientist at Uber AI Labs.

Anastasia Marchenkova

An invitation from Anastasia Marchenkova

Hya, after stints as a quantum researcher at Georgia Tech Quantum Optics & Quantum Telecom Lab, and the University of Maryland Joint Quantum Institute, I’m now working on superconducting qubit quantum processors at Bleximo. I’ll be speaking during Algorithm Conference in Austin, Texas, July 16 – 18, 2020. Meet me there and let’s chat about progress and hype in quantum computing.