Hi, in this post I want to share how to build a simple, cheap Docker server container hosted on a Raspberry PI.
As always I was looking for a fast and easy way to test my code and experiments.
Here comes Photon OSTM from vm-ware, an open source minimal Linux container optimized for vm-ware infrastructure that the latest release 3.0 has introduced the ARM64 support, so it can run on a Raspberry Pi 3.
Let’s start and download the latest ready to flash image for Raspberry.
As you can see it’s only 53MB size and 512MB once decompressed.
Flash it on a uSD card with your favorite imager tool, I use win32diskimager on my platform. During the first boot the image will autoresize to use all the available space.
You can login directly from raspberry or if look on your DHCP server you should find an IP for photon-rpi3 hostname and open the console ssh by using:
root as username
changeme as password
first you will be asked to change the password for security; retype the old pass changeme and then put a new one.
Photon OS use tdnf as package manager so to update all at the last release launch:
tdnf -y distro-sync
However the Docker service is not installed yet, but first we will install some other useful tools.
If you need to change your keyboard layout:
tdnf -y install kbd
then to have a list of available keymaps:
and to change it:
localectl set-keymap us
the vim text editor is already installed but I prefer nano so:
tdnf -y install nano
to set a static IP:
and set your network parameters:
to activate the network changes:
chmod 644 /etc/systemd/network/10-static.network
systemctl restart systemd-networkd
If you made the changes by an ssh console now reconnect with the new ip address.
Now some optional settings with a netmanger:
tdnf -y install netmgmt
The following fix should be applied cause netmgmt broke names resolution
rm -f /etc/resolv.conf
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
to set others network configuration like ntp server:
netmgr ntp_servers --add --servers 0.pool.ntp.org
netmgr ntp_servers --add --servers 1.pool.ntp.org
or the hostname:
netmgr hostname --set --name <hostname>
After that we are ready to install Docker.
First install the docker service
tdnf -y install docker
systemctl enable docker
systemctl start docker
in addition to see docker in action we will install portainer to make also things easy to handle:
docker pull portainer/portainer
we create a volume to persist the data configuration
docker volume create portainer_data
then we start the container
docker run -d -p 8000:8000 -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
open your browser and navigate to the IP of the raspberry Pi
the first time portainer will ask you the creation of the admin user
then select to handle the local environment and connect
Now you can handle your images and containers in a simply way
Next time I’ll show you how powerful could be this system.