Docker is is on everyone’s lips and now you can also use Docker on the Raspi. But one is not enough, we’ll install a Docker Swarm Cluster. If you’d like to know more about Docker and Swarm see the homepage of Docker Community.
First install a fresh Rasbian Stretch image like explained here:
Raspberry Pi Headless Installation with SSH enabled and WLAN
Update your packages to the newest versions and install some dependencies.
sudo apt-get update && sudo apt-get upgrade sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
Docker now supports also Debian Stretch (Docker CE Installation Guide)
So you can install Docker easiely with a Helper Script. Download the Script and execute it:
curl -fsSL get.docker.com -o get-docker.sh sudo sh get-docker.sh
After successful setup, you can add the user ‚pi‘ to the ‚docker‘ group, to directly execute docker commands
sudo usermod -aG docker pi
After a reboot, you can execute the docker commands with your ‚pi‘ login:
docker run hello-world
Initializing a Swarm Cluster
To initialize the Docker Swarm Cluster execute the following command on the first Docker instance:
docker swarm init Swarm initialized: current node (7nkdamk2m1tdhjzf45gfk5o91) is now a manager. To add a worker to this swarm, run the following command: docker swarm join \ --token SWMTKN-1-4ynwgkfmjkj937j7kxlyll7ncucvo8jawijv8lybxourfm2d6n-dcol6t8ulsdl7axyjg2q0moqp \ 192.168.2.58:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
If you get this error…
docker swarm init Error response from daemon: could not choose an IP address to advertise since this system has multiple addresses on interface wlan0 (fdde:530f:b4e8::f8a and fdde:530f:b4e8:0:ba66:db42:43a1:46eb) - specify one with --advertise-addr
.. you can join one of the IPv6 adresses with –advertise-addr or you can instead disable IPv6 completely:
/etc/sysctl.conf net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
After successfully initializing the cluster, you can get a list of cluster nodes with this command:
docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 7nkdamk2m1tdhjzf45gfk5o91 * dockerpi1 Ready Active Leader
To add a second instance as worker node, execute the docker swarm join command, like you can see in the output of the docker swarm init command:
docker swarm join \ > --token SWMTKN-1-4ynwgkfmjkj937j7kxlyll7ncucvo8jawijv8lybxourfm2d6n-dcol6t8ulsdl7axyjg2q0moqp \ > 192.168.2.58:2377 This node joined a swarm as a worker.
Docker Compose Installation
Docker Compose Documentation. To Install Docker Compose use this commands:
sudo apt-get install python-pip sudo pip install docker-compose
docker-compose version docker-compose version 1.16.1, build 6d1ac219 docker-py version: 2.5.1 CPython version: 2.7.13 OpenSSL version: OpenSSL 1.1.0f 25 May 2017
Schreibe einen Kommentar