Skip to main content

Raspberry Pi - Setup Raspberry Pi OS, Network Configuration, Install Docker & Docker Compose

567 words·
Raspberry Pi Docker NMCLI Linux
Table of Contents

I have tested the following setup on a Raspberry Pi 5 with a 64-bit quad-core Cortex-A76 processor and 8GB RAM.

Raspberry Pi OS Lite
#

The Raspberry Pi OS Lite version is the lightweight version of the Raspberry Pi OS (Debian Booksworm port) without the graphical desktop environment.


Raspberry Pi Imager
#

  • Use the Raspberry Pi Imager to install the OS onto the MicroSD Card
# Download Raspberry Pi Imager
https://www.raspberrypi.com/software/
  • Define the hardware, select the OS and select the micro SD card
  • Edit settings
  • Define a user & pw and the locale settings
  • Enable SSH
  • Wait till the setup has finished

Login & Root
#

  • Use the in the setup defined user to ssh into the Raspberry Pi

In Raspberry Pi OS the root user does not have a password set by default for security reasons. This means you cannot directly log in as root or switch to the root user using the su (substitute user) command without a password. Instead, the preferred way to perform tasks as the root user is by using the sudo command. Optional it’s possible to define a password for the root user with the following command: sudo passwd root


NeoVIM
#

# Install NeoVIM
sudo apt install neovim -y

# Open file in neoVIM
nvim filename
# Change default editor
sudo update-alternatives --config editor

Networking: NMCLI
#

The latest version of Raspberry Pi OS Lite uses nmcli to configure the network.

Find the connection name
#

# List network interfaces / status
nmcli dev status

# Shell output:
DEVICE         TYPE      STATE                   CONNECTION
eth0           ethernet  connected               Wired connection 1

Static IPv4 Address
#

  • Define a static IPv4 address
# Define a static IPv4 address
sudo nmcli con mod "Wired connection 1" ipv4.addresses 192.168.10.20/24 ipv4.gateway 192.168.10.1 ipv4.dns "1.1.1.1,8.8.8.8" ipv4.method manual

Apply Changes
#

# Apply changes
sudo systemctl restart NetworkManager

# Alternative: Reboot to apply the settings
sudo reboot

DHCP
#

  • Reset to DHCP
# Set to DHCP
sudo nmcli con mod "Wired connection 1" ipv4.method auto

VLAN
#

# Create a VLAN interface eth0.99 on top of eth0 with VLAN ID 99
sudo nmcli con add type vlan con-name eth0.99 ifname eth0.99 dev eth0 id 99

# Configure the IP Address
sudo nmcli con mod eth0.99 ipv4.addresses 10.10.99.11/24 ipv4.gateway 10.10.99.1 ipv4.dns "1.1.1.1,8.8.8.8" ipv4.method manual

# Enable the interface
sudo nmcli con up eth0.99
# Delete VLAN interface
sudo nmcli connection delete eth0.99

Install Docker & Docker Compose
#

  • Installation script
#!/bin/bash

# REF:https://docs.docker.com/engine/install/debian/#install-using-the-repository 

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
  • Install Docker & Docker Compose
# Create a file and insert script
vi install-docker.sh

# Change file mode to executable
chmod +x install-docker.sh

# Run installation script
./install-docker.sh

# Add user "username" to the Docker group
sudo adduser username docker

# Check Docker version
docker --version

Appendix
#

Wattage
#

My Raspberry Pi 5 (64-bit quad-core Cortex-A76 processor / 8GB RAM) running Raspberry Pi OS Lite is using 3,5 watt in idle.


Links #

# Download Raspberri Pi Imager
https://www.raspberrypi.com/software/

# Download ISO
https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit