Docker Installation - Geodels/geodels-libs GitHub Wiki

About | Input file | Docker Installation | Running Image

← Previous topic: Input file | Next topic: Running Image →


A full documentation regarding docker installation and usability is beyond the scope of this wiki. Below are some of the main steps but a more complete description can be found:

We will be using the Docker Community Edition, which is a free of cost version of Docker.

Docker CE is supported on macOS, Windows 10, Ubuntu 14.04, 16.04, 17.04 and 17.10; Debian 7.7,8,9 and 10; Fedora 25, 26, 27; and centOS. While you can download Docker CE binaries and install on your Desktop Linux systems, I recommend adding repositories so you continue to receive patches and updates.

Install Docker CE on Desktop Linux

You don’t need a full blown desktop Linux to run Docker, you can install it on a bare minimal Linux server as well, that you can run in a VM. In this tutorial, I am running it on Fedora 27 and Ubuntu 17.04 running on my main systems.

Ubuntu Installation

First things first. Run a system update so your Ubuntu packages are fully updated:

$ sudo apt-get update

Now run system upgrade:

$ sudo apt-get dist-upgrade

Then install Docker PGP keys:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Update the repository info again:

$ sudo apt-get update

Now install Docker CE:

$ sudo apt-get install docker-ce

Once it's installed, Docker CE runs automatically on Ubuntu based systems. Let’s check if it’s running:

$ sudo systemctl status docker

You should get the following output:

docker.service - Docker Application Container Engine
  Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
  Active: active (running) since Thu 2017-12-28 15:06:35 EST; 19min ago
    Docs: https://docs.docker.com
Main PID: 30539 (dockerd)

Since Docker is installed on your system, you can now use Docker CLI (Command Line Interface) to run Docker commands. Living up to the tradition, let’s run the ‘Hello World’ command:

$ sudo docker run hello-world
YMChR_7xglpYBT91rtXnqQc6R1Hx9qMX_iO99vL8
Congrats! You have Docker running on your Ubuntu system.  

Installing Docker CE on Fedora

Things are a bit different on Fedora 27. On Fedora, you first need to install def-plugins-core packages that will allow you to manage your DNF packages from CLI.

$ sudo dnf -y install dnf-plugins-core

Now install the Docker repo on your system:

$ sudo dnf config-manager \
    --add-repo \
    https://download.docker.com/linux/fedora/docker-ce.repo

It’s time to install Docker CE:

$ sudo dnf install docker-ce

Unlike Ubuntu, Docker doesn’t start automatically on Fedora. So let’s start it:

$ sudo systemctl start docker

You will have to start Docker manually after each reboot, so let’s configure it to start automatically after reboots. $ systemctl enable docker Well, it’s time to run the Hello World command:

$ sudo docker run hello-world

Congrats, Docker is running on your Fedora 27 system.

Cutting your roots

You may have noticed that you have to use sudo to run Docker commands. That’s because of Docker daemon’s binding with the UNIX socket, instead of a TCP port and that socket is owned by the root user. So, you need sudo privileges to run the docker command. You can add system user to the docker group so it won’t require sudo:

$ sudo groupadd docker

In most cases, the docker user group is automatically created when you install Docker CE, so all you need to do is add your user to that group:

$ sudo usermod -aG docker $USER

To test if the group has been added successfully, run the groups command against the name of the user:

$ groups swapnil

(Here, Swapnil is the user.)

This is the output on my system:

$ swapnil : swapnil adm cdrom sudo dip plugdev lpadmin sambashare docker

You can see that the user also belongs to the docker group. Log out of your system, so that group changes take effect. Once you log back in, try the Hello World command without sudo:

$ docker run hello-world

You can check system wide info about the installed version of Docker and more by running this command:

$ docker info

Install Docker CE on macOS and Windows

You can easily install Docker CE (and EE) on macOS and Windows.

Download the official Docker for Mac and install it the way you install applications on macOS, by simply dragging them into the Applications directory. Once the file is copied, open Docker from spotlight to start the installation process. Once installed, Docker will start automatically and you can see it in the top bar of macOS.

macOS is UNIX, so you can simply open the terminal app and start using Docker commands natively. Test the hello world app:

$ docker run hello-world

Congrats, you have Docker running on your macOS.

Docker on Windows 10

You need the latest version of Windows 10 Pro or Server in order to run/install Docker on it. If you are not fully updated, Windows won’t install Docker. I got an error on my Windows 10 system and had to run system updates. My version was still behind, and I hit this bug. So, if you fail to install Docker on Windows, just know you are not alone. Keep an eye on that bug to find a solution.

Once you install Docker on Windows, you can either use bash shell via WSL or use PowerShell to run docker commands. Let’s test the “Hello World” command in PowerShell:

PS C:\Users\swapnil> docker run hello-world

Congrats, you have Docker running on Windows.