How to: Install docker on OpenMediaVault 5 (OMV5) easily & How to: Configure docker (Docker Storage) to use specific location to store files/container/images other than default location easily

Intro

By default, OMV-Extra use “/var/lib/docker” for docker storage, which is used for Docker images and containers storage, which is not desired if we have other storage location defined on OMV, e.g. our data drive/partition/mount point, here we will configure a specific location on data drive for Docker storage.

Background

In this guide, we have a software RAID 10 with 4 hard drives configured simply by using OMV web gui.

RAID 10 on OMV 5
RAID 10 on OMV 5

We have also created a file system on the RAID for data storage with Label “FSonRAID”

FSonRAID
FSonRAID

Preparation

1 Install OMV-Extras: How to: Install omv-extras for Open Media Vault (OMV)

2 Make sure OMV-Extras is install correctly

3 Make sure we have created file system for storage purpose correctly

4 Make sure OMV is up to date, login to OMV webui, under “System”, click on “Update Management”, Update all items if there is any

OMV5 - Update system
OMV5 – Update system

5 Login to OMV terminal or via SSH (Usually the system has a different username and password from Web GUI.)

Use following command to confirm the mount point

ls -ahl /srv

We will see a folder with name of “dev-disk-by-label-FSonRAID” (The full path is “/srv/dev-disk-by-label-FSonRAID”), in your case, if you have created the file system with other Label name e.g. MyFileSystem, it will be “dev-disk-by-label-MyFileSystem”

There are two different methods to create a dedicated folder for docker to use.

The first method is suggested for security reasons, for maximum convenience we can use the second method, it will be easier to mess up docker and less secure though, unless you have configured the folder permission correctly.

2 Method 1 – Dedicate folder

For this method we can continue from the above steps

2.1 Think of a folder name for docker storage, here we use “docker”, make sure the file system we want to use is the right one with correct label, here it is “dev-disk-by-label-FSonRAID”, thus the full path will be “/srv/dev-disk-by-label-FSonRAID/docker” in this example (Note: If you have other folders under the file system, use following command to double check, make sure use a non-existing name for the new folder for docker storage!)

ls -ahld /srv/dev-disk-by-label-FSonRAID/*

2.2 Navigate to “System – OMV-Extras”

2.3 Click on “Docker”

Enter desired full path for “Docker Storage”, here we use “/srv/dev-disk-by-label-FSonRAID/docker”, click on “Save” button to save the path

Configure path for docker on OMV5
Configure path for docker on OMV5

2.4 Now click on “Docker” button, then click on “Install” to Install Docker (Docker can also be installed manually via terminal/SSH, here we take easier approach)

OMV 5 Install Docker
OMV 5 Install Docker

2.5 Once done, the folder “/srv/dev-disk-by-label-FSonRAID/docker” will be created

Also, following folders will be created

Folders in docker folder
Folders in docker folder

Now we can start to use docker with OMV 5

Note:

We can actually turn this method to method 2 later, if we want, we can simply Add a shared folder then select the “/docker” to be the path. (Make sure the Permissions is set correctly, otherwise docker will have error or there will be no security at all for all docker data)

3 Method 2 – Shared folder

With this method, we can easily inspect docker storage.

Warning: This method is not suggested unless you know what you are doing or it’s for testing only or you absolutely do no care about security.

3.1 Navigate to”Access Rights Management – Shared Folders”

OMV - Access Rights Manager - Shared Folders
OMV – Access Rights Manager – Shared Folders

3.2 Click on “Add” button, fill/select necessary details to create a new shared folder

OMV Create Shared folder
OMV Create Shared folder

3.3 Use following command on terminal or via SSH to double check the folder is created

ls -ahld /srv/dev-disk-by-label-FSonRAID/*
ls command to show folders
ls command to show folders

3.4 Now go back to OMV web GUI follow step 2.2 to step 2.4 (Except this time, we need to use “/srv/dev-disk-by-label-FSonRAID/SharedFolder” for step 2.3

Once done, we now have docker storage in a shared folder, which we can easily use Windows Share/SMB to open and view docker image rather than use terminal/SSH etc.


How to: Create Docker Swarm Cluster (With 3 servers) Easily (And install portainer to manage them)

Purpose of this guide

We will learn how to create a docker swarm cluster with 1 manager node and 2 worker nodes

What do we need to follow this guide

  • A spare computer with Windows operating system (Windows/macOS/Linux) as working PC
  • 3 up to date Ubuntu Server 19.10 /Linux servers (Can be real server can be virtual machines, in this guide we are using Ubuntu server 19.10) [Tips: Virtual machine is recommended for this guide, since we can easily take snapshots and restore easily if something goes wrong]
  • Each of them should at least have 2 GB RAM
  • Servers and the working PC have access to internet
  • Server must be connected to a same LAN
  • SSH client on the working PC (It’s will be easier when copy/paste join tokens among servers)

Tasks in this guide

  1. Before creating the docker swarm cluster, we will need to configure static IP address for each server
  2. Install docker on each server
  3. Configure Manager node
  4. Configure worker node 1
  5. Configure worker node 2
  6. Check docker nodes connection
  7. Bonus: Install portainer to manage a Linux swarm cluster with portainer server and the portainer agent (Not required for the docker swarm cluster)

Begin the journey

1 Configure static IP addresses for 3 servers

(Important Note: You do not have to use same IP address as in this guide, the IP address assigned form your router’s DHCP can be used to configure as static IP address on the server as a temporary solution, e.g. if your computer is getting address like 10.0.0.10, you can use 10.0.0.100, 10.0.0.101, 10.0.0.102 as their static address. For long term usage, we should take those address out of the DHCP address pool, or IP address conflict/duplicate IP address issue can occur, you can also configure static IP address from your router as well rather than on the server although configure on the server is preferred )

Manager node – 192.168.247.129

If you don’t understand or can’t follow Step 1.1 to Step 1.6, have a look on this guide first to understand how to use netplan/configure static IP address with netplan: How to: Set/Configure Static IP Address/DHCP for Ubuntu Server/Desktop 18.04/19.04/19.10 via Terminal using netplan then continue from here

1.1 Change current directory to “/etc/netplan”

cd /etc/netplan

1.2 List files within the folder

ls

There should be a file ending with “.yaml”, in this example we have “50-cloud-init.yaml” your might be different, if so, use that one from your directory

1.3 We need to modify that file to configure static IP address

sudo nano 50-cloud-init.yaml

1.4 Change from “Before” to “After”, make sure you have correct IP address configured, again, you do not need to use the same IP address form here, make sure you have configured IP address, gateway4 and nameservers correctly.

Before

# This file is generated from information provided by                                                                   # the datasource.  Changes to it will not persist across an instance.                                                   # To disable cloud-init's network configuration capabilities, write a file                                              # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:                                              # network: {config: disabled}                                                                                           network:
    ethernets:                                                                                                                  
        ens33:                                                                                                                      
            dhcp4: true                                                                                                     
    version: 2

After

# This file is generated from information provided by                                                                   # the datasource.  Changes to it will not persist across an instance.                                                   # To disable cloud-init's network configuration capabilities, write a file                                              # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:                                              # network: {config: disabled}                                                                                           network:
    ethernets:                                                                                                                  
        ens33:                                                                                                                      
            dhcp4: no
            addresses: [192.168.247.129/24]
            gateway4: 192.168.247.2
            nameservers:
              addresses: [192.168.247.2, 8.8.8.8]                                                                                                     
    version: 2

1.5 Use Ctrl + X, then Hit Y, then hit Enter key to save and exit the nano editor

1.6 Apply changes

sudo netplan apply

1.7 Make sure the IP address is configured correctly

ip a
ip a
ip a

1.8 Make sure the configured IP and DNS works by using following commands

# Check DNS server, IP address should be returned
dig bing.com
 
# Check the network, time of round trip should be returned
ping bing.com -c 5

Worker node 1 – 192.168.247.130

1.9 Same step as from Step 1.1 to Step 1.7 but with different IP address

Worker node 2 – 192.168.247.131

1.10 Same step as from Step 1.1 to Step 1.7 but with different IP address

2 Install docker on each server

Manager node – 192.168.247.129

2.1 Install docker

sudo apt install -y docker.io

Worker node 1 – 192.168.247.130

2.2 Install docker

sudo apt install -y docker.io

Worker node 1 – 192.168.247.131

2.3 Install docker

sudo apt install -y docker.io

3 Configure Manager node – 192.168.247.129

3.0 Preparation/Suggestion for using SSH client

(Use SSH client to connect to the server from the working PC, for Windows we can use PowerShell or Windows Terminal with ssh command, for Linux and macOS we can just use terminal with ssh command)

e.g.

(To connect to 192.168.247.129, we can use following command, then type yes, hit Enter key, type password to connect)

# Format
ssh [email protected]
 
# Example For this guide
ssh [email protected]

3.1 Initialize docker swarm manager [1]

sudo docker swarm init
sudo docker swarm init
sudo docker swarm init

3.2 Copy the command for adding a worker to this swarm, the following is for this guide, yours will be different, you will have to use yours

docker swarm join --token SWMTKN-1-5vphj6kj8t6z5yz45jq97vpe742avhl7md4905o796kkupnu1t-5oypobnbtpb3kksvv5s2k15f5 192.168.247.129:2377

Note: If you have missed that token somehow, in order to show the token again

# Show token for adding worker
sudo docker swarm join-token worker
 
# Show token for adding manager
sudo docker swarm join-token manager
Show docker swarm token for adding worker and manager nodes
Show docker swarm token for adding worker and manager nodes

4 Configure worker node 1 – 192.168.247.130

4.1 Adding worker node 1 to swarm as a worker (Execute following command on worker node 1) (The command was copied from Step 3.2)

sudo docker swarm join --token SWMTKN-1-5vphj6kj8t6z5yz45jq97vpe742avhl7md4905o796kkupnu1t-6mrz20tzuovi3rivfw3ivm6wv 192.168.247.129:2377
Successfully executed command on worker node 1, worker node 1 added to swarm as a worker
Successfully executed command on worker node 1, worker node 1 added to swarm as a worker

5 Configure worker node 2 – 192.168.247.131

5.1 Adding worker node 2 to swarm as a worker (Execute following command on worker node 2) (The command was copied from Step 3.2)

sudo docker swarm join --token SWMTKN-1-5vphj6kj8t6z5yz45jq97vpe742avhl7md4905o796kkupnu1t-6mrz20tzuovi3rivfw3ivm6wv 192.168.247.129:2377
Successfully executed command on worker node 2, worker node 2 added to swarm as a worker
Successfully executed command on worker node 2, worker node 2 added to swarm as a worker

6 Check docker nodes connection

6.1 Execute following command on manager node

sudo docker node ls
sudo docker node ls output on manager node
sudo docker node ls output on manager node

Now the docker swarm cluster is created and ready for use

7 Bonus: Install portainer to manage a Linux swarm cluster with portainer server and the portainer agent (Not required for the docker swarm cluster)

7.1 Execute following commands on the manager node [2]

curl -L https://downloads.portainer.io/portainer-agent-stack.yml -o portainer-agent-stack.yml
 
docker stack deploy --compose-file=portainer-agent-stack.yml portainer
Install portainer to manage the LLLinux swarm cluster with portainer server and the portainer agent
Install portainer to manage the LLLinux swarm cluster with portainer server and the portainer agent

7.2 Open portainer web GUI, configure username and password (http://manager node’s IP address:9000) then click on “Create user”

In this guide it is http://192.168.247.129:9000

portainer web GUI
portainer web GUI
portainer home page
portainer home page

Now the portainer installation and configuration is done for managing Linux swarm cluster with portainer server and portainer agent

Click on “primary” we can view the dashboard

portainer dashboard
portainer dashboard

Click on “Go to cluster visualizer” we can see the swarm cluster details

Swarm, Cluster visualizer
Swarm, Cluster visualizer

App Templates – stack

App Templates - stack
App Templates – stack

Stacks

Stacks
Stacks

Services

Services
Services

Containers

Containers
Containers

Images

Images
Images

Networks

Networks
Networks

Volumes

Volumes
Volumes
Volumes
Volumes

Configs

Configs
Configs

Secrets

Secrets
Secrets

Swarm

Swarm
Swarm

Resources

[1] “Run Docker Engine in swarm mode”, Docker Documentation, 2020. [Online]. Available: https://docs.docker.com/engine/swarm/swarm-mode.

[2] “Installation”, Portainer.io, 2020. [Online]. Available: https://www.portainer.io/installation


How to: Install Portainer on Ubuntu (Linux etc.) (Single node/Standalone Linux Docker host/Single node swarm cluster)

What is portainer?

An lightweight, open source and easy to use tool for managing Docker environment with web GUI, it can also manage docker swarm cluster.

If you are after some heavy weight management software alternatives, Rancher can be a good one to look into. It’s an open source multi-cluster orchestration platform.

How to Install portainer from scratch?

1 Install docker first

# For Ubuntu
sudo apt install docker.io

2 Install portainer

$ sudo docker volume create portainer_data
$ sudo docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

3 Check server IP address

ip a

4 Login to portainer and configure desired Username and Password, then click on “Create user” to proceed

http://ipaddress:9000
Configure portainer login details
Configure portainer login details

5 If you know what you are doing you can configure portainer by selecting “Remote” or “Agent” or “Azure” otherwise, we select “Local” then click on “Connect”

Configure portainer - Local
Configure portainer – Local

6 We have successfully installed, configured and logged into portainer

portainer home screen
portainer home screen

Bonus

portainer – Home

portainer - home
portainer – home

portainer – Local Dashboard

portainer - local Dashboard
portainer – local Dashboard

portainer – App Templates

portainer - App Templates
portainer – App Templates

portainer – Stacks

portainer - Stacks
portainer – Stacks

portainer – Containers

portainer - Containers
portainer – Containers

portainer – Images

portainer - Images
portainer – Images

portainer – Networks

portainer - Networks
portainer – Networks

portainer – Volumes

portainer - Volumes
portainer – Volumes

portainer – Events

portainer - Events
portainer – Events

portainer – Host

portainer - Host
portainer – Host

Resources

portainer: https://www.portainer.io

Rancher: https://rancher.com