Posted on

In preperation for other projects I wishted to get Docker running on a Raspberry Pi. The guide below shows how I installed Docker on Photon OS and set up the Wi-Fi.

Preparing the SD card

Start by download Photon OS for Raspberry Pi. This can by downloaded at the VMWare site.

I am using the following image:

file: photon-rpi3-3.0-26156e2.tar.xz
size: 53M
sha1: f11515e5d8ab53b328789ff0b27aceb121c1772f

Extract the .xz archive and the .tar archive so you only have the .raw file. Install the .raw file using Etcher.

Preparing to flash the Photon OS image to SD Card

Preparing to flash the Photon OS image to SD Card

Flashing the SD Card

Flashing the SD Card

SD Card prepared

SD Card prepared

Insert the SD card into the Raspberry Pi and insert power cable.

Finding the IP address

My Pi is connected via Ethernet. I use NMAP for Windows to find the ip address for the Pi using:

nmap -sP 192.168.8.0/24
C:\Users\Arnav>nmap -sP 192.168.8.0/24
Starting Nmap 7.70 ( https://nmap.org ) at 2019-06-02 17:51 W. Europe Summer Time
/***/
Nmap scan report for photon-rpi3.jain.lan (192.168.8.228)
Host is up (0.0030s latency).
MAC Address: B8:27:EB:5C:D3:AB (Raspberry Pi Foundation)
/***/
Nmap done: 256 IP addresses (15 hosts up) scanned in 7.71 seconds

Connect to Raspberry PI

Connect to Pi using ssh and change password on first connection. Default logon is root / changeme.

ssh root@photon-rpi3.jain.lan
C:\Users\Arnav>ssh root@photon-rpi3.jain.lan
Password:
You are required to change your password immediately (administrator enforced)
Changing password for root.
Current password: ****
New password: ****
Retype new password: ****
 15:58:48 up 11 min,  0 users,  load average: 0.08, 0.03, 0.03

24 Security notice(s)
Run 'tdnf updateinfo info' to see the details.
root@photon-rpi3 [ ~ ]#

Installing Docker

tdnf install docker
root@photon-rpi3 [ ~ ]# tdnf install docker

Installing:
libseccomp                           aarch64            2.4.0-1.ph3              photon-updates     307.65k 315032
libapparmor                          aarch64            2.13-7.ph3               photon-updates      66.57k 68168
libsepol                             aarch64            2.8-1.ph3                photon             611.89k 626576
libselinux                           aarch64            2.8-1.ph3                photon             174.16k 178338
libltdl                              aarch64            2.4.6-3.ph3              photon              35.53k 36384
device-mapper-libs                   aarch64            2.02.181-1.ph3           photon             315.39k 322960
docker                               aarch64            18.06.2-2.ph3            photon-updates     154.39M 161893076

Total installed size: 155.87M 163440534
Is this ok [y/N]:y

Downloading:
libseccomp                               83992    100%
libapparmor                              39330    100%
libsepol                                275180    100%
libselinux                               84756    100%
libltdl                                  24218    100%
device-mapper-libs                      149078    100%
docker                                43826910    100%
Testing transaction
Running transaction
Installing/Updating: libsepol-2.8-1.ph3.aarch64
Installing/Updating: libselinux-2.8-1.ph3.aarch64
Installing/Updating: device-mapper-libs-2.02.181-1.ph3.aarch64
Installing/Updating: libltdl-2.4.6-3.ph3.aarch64
Installing/Updating: libapparmor-2.13-7.ph3.aarch64
Installing/Updating: libseccomp-2.4.0-1.ph3.aarch64
Installing/Updating: docker-18.06.2-2.ph3.aarch64

Complete!
root@photon-rpi3 [ ~ ]#

Starting and enabling docker

Start Docker service:

systemctl start docker

Enable Docker service (so it starts with the Pi)

systemctl enable docker
root@photon-rpi3 [ ~ ]# systemctl start docker
root@photon-rpi3 [ ~ ]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
root@photon-rpi3 [ ~ ]#

Testing the docker installation

Hello World

Pulling the latest hello-world image:

docker pull hello-world
root@photon-rpi3 [ ~ ]# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
3b4173355427: Pull complete
Digest: sha256:0e11c388b664df8a27a901dce21eb89f11d8292f7fca1b3e3c4321bf7897bffe
Status: Downloaded newer image for hello-world:latest
root@photon-rpi3 [ ~ ]#

Running the image:

docker run hello-world
root@photon-rpi3 [ ~ ]# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm64v8)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

root@photon-rpi3 [ ~ ]#

nginx

Pulling and running the lightweight nginx:alpine image:

docker run -p 80:80 nginx:alpine
root@photon-rpi3 [ ~ ]# docker run -p 80:80 nginx:alpine
Unable to find image 'nginx:alpine' locally
alpine: Pulling from library/nginx
0362ad1dd800: Pull complete
28925c38cc7e: Pull complete
694c9daeeb8b: Pull complete
da33a7c6655b: Pull complete
Digest: sha256:57a226fb6ab6823027c0704a9346a890ffb0cacde06bc19bbc234c8720673555
Status: Downloaded newer image for nginx:alpine
192.168.8.10 - - [02/Jun/2019:17:01:40 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0" "-"
192.168.8.10 - - [02/Jun/2019:17:01:40 +0000] "GET /favicon.ico HTTP/1.1" 404 154 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0" "-"
2019/06/02 17:01:40 [error] 8#8: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 192.168.8.10, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "photon-rpi3.jain.lan"
Webserver running on Pi

Webserver running on Pi

Setting up Wi-Fi

Using the Pi, it is more convenient to use Wi-Fi rather than using ethernet, so let’s enable and connect to Wi-Fi.

Start the wpa_supplicant service

systemctl start wpa_supplicant@wlan0

Enabling the wpa_supplicant service (so it starts with the Pi)

systemctl enable wpa_supplicant@wlan0

Check wheter the service has started

systemctl status wpa_supplicant@wlan0

Edit the dhcp settings to get DHCP for wlan0 and not eth0

cat /etc/systemd/network/99-dhcp-en.network
root@photon-rpi3 [ ~ ]# cat /etc/systemd/network/99-dhcp-en.network
[Match]
Name=e*

[Network]
DHCP=yes
IPv6AcceptRA=no
root@photon-rpi3 [ ~ ]#

Change “Name=e*” to “Name=w*” using vi. (Remember «Escape», :wq to save and quit)

vi /etc/systemd/network/99-dhcp-en.network

Verify the change

cat /etc/systemd/network/99-dhcp-en.network
root@photon-rpi3 [ ~ ]# cat /etc/systemd/network/99-dhcp-en.network
[Match]
Name=w*

[Network]
DHCP=yes
IPv6AcceptRA=no
root@photon-rpi3 [ ~ ]#

Restart networking

systemctl restart systemd-networkd

We ofcourse need to configure the SSID using the wpa_passphrase utility:

wpa_passphrase «SSID» «PassPhrase» >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

Finally reboot device:

reboot

Summary:

root@photon-rpi3 [ ~ ]# systemctl start wpa_supplicant@wlan0
root@photon-rpi3 [ ~ ]# systemctl enable wpa_supplicant@wlan0
Created symlink /etc/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service → /lib/systemd/system/wpa_supplicant@.service.
root@photon-rpi3 [ ~ ]# systemctl status wpa_supplicant@wlan0
● wpa_supplicant@wlan0.service - WPA supplicant (wlan0)
   Loaded: loaded (/lib/systemd/system/wpa_supplicant@.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sun 2019-06-02 16:45:45 UTC; 7s ago
 Main PID: 665 (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 564)
   Memory: 2.1M
   CGroup: /system.slice/system-wpa_supplicant.slice/wpa_supplicant@wlan0.service
           └─667 /usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant-wlan0.conf -B -i wlan0

Jun 02 16:45:45 photon-rpi3 systemd[1]: Starting WPA supplicant (wlan0)...
Jun 02 16:45:45 photon-rpi3 wpa_supplicant[665]: Successfully initialized wpa_supplicant
Jun 02 16:45:45 photon-rpi3 wpa_supplicant[665]: rfkill: Cannot open RFKILL control device
Jun 02 16:45:45 photon-rpi3 systemd[1]: Started WPA supplicant (wlan0).
root@photon-rpi3 [ ~ ]# cat /etc/systemd/network/99-dhcp-en.network
[Match]
Name=e*

[Network]
DHCP=yes
IPv6AcceptRA=no
root@photon-rpi3 [ ~ ]# vi /etc/systemd/network/99-dhcp-en.network
root@photon-rpi3 [ ~ ]# cat /etc/systemd/network/99-dhcp-en.network
[Match]
Name=w*

[Network]
DHCP=yes
IPv6AcceptRA=no
root@photon-rpi3 [ ~ ]# systemctl restart systemd-networkd
root@photon-rpi3 [ ~ ]# wpa_passphrase Jain08_24 Akalla16476 >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
root@photon-rpi3 [ ~ ]# reboot
Connection to photon-rpi3.jain.lan closed by remote host.
Connection to photon-rpi3.jain.lan closed.
comments powered by Disqus