Intro

This example Uses 4 Raspberry Pi Model 3 A+ each with 16Gb Micro SD Card

 

Headless Install of Raspbian Lite

Base Image Install

Install Raspbian Buster Lite onto Micro SD Card

Download Raspbial Buster Lite from here https://www.raspberrypi.org/downloads/raspbian/ 

check the SHA-256 hash matches ( sha256sum <filename> then unzip

Insert Micro SD Card and run sudo fdisk -l to identify the micro sd card

Unmount the above device sudo umount /dev/<device name>1

Apply the image sudo dd bs=1M if=<filename>.img of=/dev/<device name>

remove and rensert the sd card to mount it

O/S Configuration

Enable SSH Access by creating an empty file called ssh in the /boot folder

Enable WIFI access by editing the file /etc/wpa_supplicant/wpa_supplicant.conf and setting the contents to :-

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
        ssid="<network ssid>"
        psk="<network password>"
        key_mgmt=WPA-PSK
}

Set host name by editing the file /etc/hosts change raspberrypi to dockerx 

also edit /etc/hostname setting the same hostname

Power Up and Install Docker

Get the ip address of each pi and add this to your hosts file

Install docker on each pi 

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh

 Allow current user to run docker commands

sudo usermod -aG docker pi

 then reboot

the test docker with

docker run hello-world

Create Docker Swarm