I found docker interesting technology something about 2 years ago, at this point I want to use it on larger scale then one machine but not necessary using cloud or kubernetes.
I just want to be able to create 3 physical machines cluster ( swarm ) and deploy applications ( services ) on it.
1. Installation Of Docker
First I will install latest docker version just by using those commands:
then I will add my user to the docker by typing :
2. Configuration Of Docker Deamon
Second I need to be able to run docker as deamon on public port and let it be 2375.
To do it I will reconfigure docker daemon
Also to get rid of -H fd:// in systemctl modify docker script
and finally start docker using
Probably I could also use some proxy since dockerd is simply http server with json api, or at least som environment variable, but this way I can learn something more about systemd shitty configurations.
3. Installation Of docker-compose And docker-machine
Third I want to also use docker-compose to manage my multiple docker container application and since it is python package I will install it with :
Last but not least I want to setup docker-machine to maintain my cluster.
I will grab latest version from https://github.com/docker/machine/releases
and just apply some console magic (I am installing version for raspberry pi 3):
So now since I got all lame docker prefixed shit in place including docker,dockerd,docker-machine,docker-compose I can add some machines to maintain and finally start to swarm my machines with containers.
4. SSH Keys
So I will be adding 3 machines and I want to access to them without password.
I will create simple configuration in /etc/hosts file for now:
First let’s create key
I will add my key to my hosts using:
5. Creation Of Docker Machine
then create one machine:
the output for raspberry pi 3 should be something like this (first failure):
But it should be running so using docker-machine ls I will get (second failure):
Ok so I need to use https instead of http with my docker deamon to fix machine listings and also provision my machines manually.
6. Certificate Authority For HTTPS Traffic.
Let’s start from locating cerfiticate authority (CA) and creating certificate for each machine.
I am using docker-machine so files should be around here:
If I didn’t have those files I can create them from command line:
Ok so now I will create certificate for pi01 machine with ip 192.168.1.101 and 127.0.0.1:
7. Docker Deamon With HTTPS Trafic
After that I can modify configuration of my docker daemon:
notice that I intentionally changed port from 2375 to 2376 so I need to change my docker-machine config file:
Now everything is all right (except active flag) with first machine:
8. Manual Provisioning Summary
Ok so since I cannot provision two other raspberry pi I will add certificates for each host and change systemctl manually.
Again this could be done using environment variables
So for me it is (in short provisioning and certificates for pi02):
add directory and create certs for ip 192.168.1.102 hostname pi02
copy to remote machine
to remote machine
restart docker service
I won’t repeat those steps for pi03.
After running those commands I have something like this:
9. Configuration of docker-swarm
Now it’s time for swarming. I will start with one host that will act as manager.
I will add other hosts as guests by simply execute command printed to console on other hosts
And after that that to see my cluster I can run command:
So there it is.
if someone want to add some machines to the swarm later or simply want to add more managers to retrieve specific command just invoke:
Next I will try to write about how to build docker applications, use docker-compose and deploy it against swarm cluster.