Initialize SWARM / Master / Slave

Following command creates a swarm on the MASTER machine:

$ docker swarm init --advertise-addr 192.168.0.23
Swarm initialized: current node (jg3z8p6rei7yk1d18disx0j5h) is now a manager.

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

    docker swarm join --token SWMTKN-1-1gp7povi99cvtn4vdcor1ehoi9l2fnkbbgasxl8sibp5osyrhx-3l6yptd5h58vssjbr52xvl9pt 192.168.0.23:2377

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

The --advertise-addr flag configures the manager node to publish its address as 192.168.0.23. The other nodes in the swarm must be able to access the manager/ MASTER at the IP address.

Beneath command shall be run on each of the SLAVE’s:

$ docker swarm join --token SWMTKN-1-1gp7povi99cvtn4vdcor1ehoi9l2fnkbbgasxl8sibp5osyrhx-3l6yptd5h58vssjbr52xvl9pt 192.168.0.23:2377

Run docker info to view the current state of the swarm:

$ docker info
Client:
 Debug Mode: false

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 7
 Server Version: 19.03.13
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: active
  NodeID: pte7g3f8qmgopajofed9r7231
  Is Manager: false
  Node Address: 192.168.0.17
  Manager Addresses:
   192.168.0.23:2377
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.4.51-v7+
 Operating System: Raspbian GNU/Linux 10 (buster)
 OSType: linux
 Architecture: armv7l
 CPUs: 4
 Total Memory: 925.9MiB
 Name: SLAVE3
 ID: 4HUF:DY2O:WTJA:Q4EV:WCIY:2HC6:OKY6:A56N:GPWN:GJQV:5DYR:N6BJ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Use Portainer to get an overview.

Official documentation:

https://docs.docker.com/engine/reference/commandline/swarm_init/

Leave a Reply

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