swarm - vimagick/rpi-bin GitHub Wiki
Build Swarm Binary (On MacOSX)
mkdir -p ~/go/src/github.com/docker/swarm/
cd ~/go/src/github.com/docker/swarm/
wget -qO- https://github.com/docker/swarm/archive/v1.2.3.tar.gz | tar xz --strip 1
GOPATH=~/go/src/github.com/docker/swarm/Godeps/_workspace:~/go CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -v -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/docker/swarm/version.GITCOMMIT=1.2.3" -o swarm-1.2.3-armv6h
!!:gs/6/7/
Build Swarm Image (On Linux)
wget https://github.com/docker/swarm/archive/v1.2.3.zip
unzip v1.2.3.zip
cd swarm-1.2.3
wget -O swarm https://github.com/vimagick/rpi-bin/raw/master/bin/swarm-1.2.3-armv6h
docker build -t easypi/swarm-arm .
docker login
docker push easypi/swarm-arm
Prepare Environment (On RaspberryPi)
$ su -l
$ cp -r ~alarm/.ssh ~
$ pacman -Syu --noconfirm
$ pacman -Sw --noconfirm --needed sudo curl docker
$ reboot
Setup Swarm Master (On MacOSX)
$ brew install docker-machine docker-swarm
$ docker-swarm create
cddc4d08cc5f9bb9d00b29d76ea26955
$ docker-machine create -d generic --generic-ip-address 192.168.1.154 --generic-ssh-user root --generic-ssh-key ~/.ssh/id_rsa --swarm --swarm-master --swarm-discovery token://cddc4d08cc5f9bb9d00b29d76ea26955 --swarm-image easypi/swarm-arm pi-master
Running pre-create checks...
Creating machine...
(pi-master) Importing SSH key...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with arch...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Configuring swarm...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env pi-master
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Stopped Unknown
pi-master - generic Running tcp://192.168.1.154:2376 pi-master (master) v1.10.3
$ eval $(docker-machine env pi-master)
$ docker info
Containers: 2
Running: 2
Paused: 0
Stopped: 0
Images: 1
Server Version: 1.10.3
Storage Driver: overlay
Backing Filesystem: extfs
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
Volume: local
Network: bridge null host
Kernel Version: 4.1.20-3-ARCH
Operating System: Arch Linux ARM
OSType: linux
Architecture: armv7l
CPUs: 4
Total Memory: 922.7 MiB
Name: pi-master
ID: VBVL:EQSI:4CZT:2TCH:35VF:U3MQ:PVXG:B2ED:OISU:YKOS:Z4GX:ODNO
WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No oom kill disable support
Labels:
provider=generic
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
easypi/swarm-arm latest 09fc9fc40faa 19 minutes ago 13.83 MB
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a502ff5618a6 easypi/swarm-arm "/swarm join --advert" 2 minutes ago Up 2 minutes swarm-agent
7a7a7335c8a0 easypi/swarm-arm "/swarm manage --tlsv" 2 minutes ago Up 2 minutes swarm-agent-master
Setup Swarm Node (On MacOSX)
$ docker-machine create \
-d generic \
--generic-ip-address 192.168.1.228 \
--generic-ssh-user root \
--generic-ssh-key ~/.ssh/id_rsa \
--swarm \
--swarm-discovery token://cddc4d08cc5f9bb9d00b29d76ea26955 \
--swarm-image easypi/swarm-arm \
--engine-label disk=8G \
pi-node-00
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Stopped Unknown
pi-master - generic Running tcp://192.168.1.154:2376 pi-master (master) v1.10.3
pi-node-00 - generic Running tcp://192.168.1.228:2376 pi-master v1.10.3
~ $ docker-swarm list token://cddc4d08cc5f9bb9d00b29d76ea26955
192.168.1.154:2376
192.168.1.228:2376
Schedule Docker Container
$ eval $(docker-machine env --swarm pi-master)
$ docker run --rm -it -e constraint:disk==8G easypi/alpine-arm sh
>>> echo 'hello world from pi-node-00'
>>> exit
References