How to set up Raspberry Pi 4B with Docker and Portainer CE

Januar 15, 2023 - Lesezeit: 5 Minuten

Raspberry Pi

In case you did not buy the bundle with the pre-formatted SD Card, start with formatting your SD Card to FAT 32.

You can do so using various tools. In case you are looking for some options, Rufus or AOMEI Partition Assistant might be worth your consideration.

Next download the Imager from https://www.raspberrypi.com/software

Since we are not looking for desktop but rather a server running 24/7, let's choose the lite version of the OS:

Raspberry Pi OS (other) > Raspberry Pi OS Lite (32-bit)

Click Shift Ctrl + X or Enter Settings to enable SSH directly. Also set the hostname so that you do not have to fiddle with your router for the IP address of your Raspberry Pi afterwards. Telemetry is not needed for our purpose so you can deactivate it. Lastly it is recommended to use your own user instead of the standard user "pi" and set an appropiate password for it.

You can also generate an empty file named "ssh" in the "boot" folder on your SD card to enable the SSH access in case is was forgotten before.

Now Remove the SD Card from your PC, plug it into your Pi, plug in the LAN cable and plug in the power cable. Your Pi will boot automatically. Find the IP for your Pi on the Router in use, or connect to your Pi using the hostname.

ssh:<user>@<ip-or-hostname>
ssh:pi@raspberrypi

Well then, let's update the OS to the latest greatest first before we continue messing around with it:

sudo apt update && sudo apt upgrade
sudo reboot
Docker Installation

Meanwhile, you can read about the Docker Installation here: https://docs.docker.com/engine/install/debian/

If you came to this page after a broken docker installation, remove it first before continue. Like so:

sudo apt-get remove docker docker-engine docker.io containerd runc

Now let's install using the convenience script:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh

If you want to test the installation first, then use the command with DRYRUN option instead

DRY_RUN=1 sudo sh ./get-docker.sh
Add your user to the docker group, then either reboot or reload the new group change:
sudo usermod -aG docker $USER
#sudo usermod -aG docker <my-user>
#sudo reboot
newgrp docker

Now verify the docker version, run a test container and show running containers:

docker –version
docker run hello-world
docker ps
Portainer Community Edition Installation

Details can be read here, remember to choose community edition: https://docs.portainer.io/start/install/server/docker/linux

First let's create a volume for data persistency:

docker volume create portainer_data

The following command will do the job for you, basically download and install the Portainer Server container: 

docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
There you go, now Portainer should be easily found as running using docker ps and via browser:
https://rspberrypi:9443
https://<ip-or-hostname>:9443
Remember that localhost:9443 only works if you are on the RaspberryPi itself.

Disable Wifi on Raspberry Pi 4B

Januar 14, 2023 - Lesezeit: ~1 Minute

sudo vi /boot/config.txt

# Find the following line:
# Additional overlays and parameters are documented /boot/overlays/README

# And add these two lines under it:
dtoverlay=disable-wifi
dtoverlay=disable-bt

# Bluetooth is also disabled. Reboot and check
ifconfig
#eth0 > LAN
#wlan0 > bad :)