Time: 30 minutes
Docker is an innovative technology that developed in a short period of time (about two years) and is in great demand in modern IT industries today.
One of the easiest things I have learned to implement is Docker on a Raspberry Pi 4b. I will out line the steps here for you to complete the task with an extra bonus for you. You will have access to one of the hottest technologies in the industry today.
I will be using some acronyms during the writing:
cli – command line interface
OS – Operating System
RPi – Raspberry Pi 4b
OPi5 – Orange Pi 5
Let’s get started with your new Docker Server:
1 – Raspberry Pi 4b Device – at least 4 gb of ram, but 2 gb would work.
2 – Rapsberry Pi Imager to burn the RPiOS to an SD Card
3 – a SD Card I would say in my opinion 32 gb at the smallest (SDXC UHD)
4 – Time you will need about 30 minutes.
5 – Burn Bullseye to Sd Card with Imager
6 – sudo nano -c /boot/cmdline.txt on Ubuntu it’s c /boot/firmware/cmdline.txt
7 – copy and paste into the above file.
“cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 swapaccount=1”
The next step is to give the Pi headless operation, add the ability to have a static DNS
8 – Copy the above line without quotes to the front of the cmdline.txt
ip=your_ip_here::gateway_here:255.255.255.0:rpi4-pimox-01:eth0:off cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 swapaccount=1
note: disable the wifi, audio, & bluetooth in the /boot/config.txt – under additional overlays section
# Disable audio (loads snd_bcm2835)
Let’s set a static IP for the device:
remove the # in front of interface, static ip, static routers, static domain_name_servers Adjust these with your ip, gateway, router and DNS Server address. Please follow the format in the screenshot.
Make sure you remove the ip line from the /boot/cmdline.txt (ip=xxx.xxx.xxx.xxx::xxx.xxx.xxx.xxx:255.255.255.0:dkrce02:eth0:off)
note: Let’s set the server’s time zone – This is important!
9 – sudo timedatectl set-timezone America/New_York && sudo reboot
note: Let’s fix the resolv.conf – I have had issues with this, so I decided to add this section
10 – sudo apt -y install resolvconf
11 – sudo systemctl start resolvconf.service
12 – sudo systemctl enable resolvconf.service
13 – sudo systemctl status resolvconf.service
Set the Permanent DNS Servers
14 – sudo nano /etc/resolvconf/resolv.conf.d/head
copy and paste the info below into the file above.
Restart the services to reflect changes
15 – sudo systemctl restart resolvconf.service
16 – sudo systemctl restart systemd-resolved.service
note: Check your hosts file make sure it’s good.
17 – cat /etc/hosts
note: look for the following or something similar.
127.0.1.1 rpi4-pimox-07.rpihobby.loc rpi4-pimox-07
Reboot the server for changes to take effect
18 – sudo reboot
note: The prep work is done Let’s get down to business.
Let’s update the repositories & Upgrade the system while we are at it.
19 – sudo apt update && sudo apt -y full-upgrade
note: if you get an error that has oldstable in it.
use this to fix it: apt update –allow-releaseinfo-change <- type it at the cli.
I like neofetch so I use it.
20 – sudo apt -y install neofetch
21 – sudo nano -c .bashrc
note: copy the following to the last line of the file.
Let’s add the git repository for pi-hosted:
22 – sudo apt -y install git
23 – sudo mkdir -p /projects
24 – cd /projects
25 – sudo git clone https://github.com/novaspirit/pi-hosted.git
Let’s install docker so we can get some containers running.
26 – ./install_docker.sh
If this is the controller node let’s install Portainer:
27 – ./intall_portainer.sh
This is an alternative: Let’s install docker so we can get some containers running.
sudo wget -qO- https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/install_docker.sh | bash
29 – sudo apt -y install docker-compose
30 – sudo docker-compose –version
BONUS: Now Let’s install portainer for your management GUI
31 – sudo wget -qO- https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/install_portainer.sh | bash
32 – sudo docker ps -a
There are plenty of youtube Videos on how to configure Portainer for your environment:
Thank you for coming by and reading this article. If you need further assistance feel free to email me or reach out to me on discord in the RPiHobby channel/server.