Docker swarm

January 3, 2018
Raspian Raspberry PI Docker

Docker Swarm (part 1)

Small howto to explain how to create a Swarm cluster with Docker. This setup has been realized with my Raspberry Pi systems but feel free to use whatever you want.

% docker swarm init
Swarm initialized: current node (iwy90it8c20vx9zbihmtsaqsi) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-3b49f4noaq1mqsltkhjybclmfzlhkjfiaff1rs509s1vek3f5k-683br7b1erxj1lxt24g88g405 192.168.1.34:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

You can specify an interface or ip if you have many. Look at the documentation

Here is a small image to explain the difference between manager and worker:

docker nodes

Very basically, managers will handle all the cluster management tasks AND execute containers. And the workers will only execute containers.

If you want to know more, the Docker documentation is here

A basic rule is to always maintain an odd number of managers to support node failures. As usual, the Docker documentation explain this very well.

* At first, you must retrieve the token. It was given to you by the *docker swarm init* command or if you has loose it : 
    ```bash
    % docker swarm join-token manager
    To add a manager to this swarm, run the following command:

        docker swarm join --token SWMTKN-1-3b49f4noaq1mqsltkhjybclmfzlhkjfiaff1rs509s1vek3f5k-crtdjmq4jaxcbsuuqgww6hdzr 192.168.1.34:2377
    ```

This command must be typed on the first node initialized.

* Connect to your another machine and type the command : 
    ```bash
    % docker swarm join --token SWMTKN-1-3b49f4noaq1mqsltkhjybclmfzlhkjfiaff1rs509s1vek3f5k-crtdjmq4jaxcbsuuqgww6hdzr 192.168.1.34:2377
    This node joined a swarm as a manager.
    ```
	
* Verify our cluster :
    ```bash
    ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
    iwy90it8c20vx9zbihmtsaqsi     docker01            Ready               Active              Leader
    keaxsm0qwne61l25hqn84zmjd *   docker02            Ready               Active              Reachable
    ```

Everything is fine ! We have a cluster of two machines (both are manager)

Hint : if you want to have a manager node that do NOT run containers, you must set it’s availability as drain

Use constraints with Swarm

September 4, 2018
Docker

Setup a Let's encrypt certificate with Traefik

May 23, 2018
Docker traefik

Traefik for the beginners

May 4, 2018
Docker traefik