Raspberry Pi Portainer: Complete Setup and Management Guide

Raspberry Pi Portainer: Complete Setup and Management Guide

Sep 4,2025

Raspberry Pi board beside the Portainer logo — Portainer on Raspberry Pi

What is Portainer?

Portainer.io logo with Docker logo side by side — Portainer and Docker integration

Portainer Raspberry Pi setup is popular because Portainer is a lightweight web interface for running and managing containers.It sits on top of Docker (and can also work with Swarm/Kubernetes) to simplify day-to-day tasks, making Raspberry Pi Docker management much easier for beginners:deploy stacks, view logs, manage volumes and networks, set environment variables, and handle image updates.

Key features and advantages over CLI-only Docker

      • Visual control of containers, images, volumes, and networks.
      • One-click stack deploys from Docker Compose.
      • Role-based access (teams/users) and registry integration.
      • Health/status visibility.
      • Safer for routine ops on shared systems; fewer typos vs. raw CLI.

Why Use Portainer on Raspberry Pi?

Benefits

Raspberry Pi Docker projects benefit because Portainer works well on limited hardware; minimal CPU at idle.

• Works well on limited hardware; minimal CPU at idle.
Easy lifecycle: pull → deploy → update → rollback from the UI.
Great for edge/IoT: pair with MQTT, Node-RED, InfluxDB, Grafana, etc.Ease on limited-resource devices
• ARM64 images supported; you can set CPU/RAM limits per container.
• Visual checks help catch runaway logs, port collisions, and volume issues.Portainer vs. Docker CLI (quick view)
• Portainer: UX, visibility, safer shared use, quick audits.
• CLI: full power, scripting/automation, fastest for advanced users.Best practice: use Portainer for routine ops and the CLI for scripting and deep troubleshooting.

Requirements

Portainer Raspberry Pi requirements are modest: Raspberry Pi 4 (4GB+ RAM) and Pi 5 recommended.

• Raspberry Pi 4 (4GB+ RAM) and Pi 5 recommended.
• OS: Raspberry Pi OS (Bookworm) or Ubuntu Server 22.04/24.04 (ARM64)
• Storage: SSD/NVMe strongly recommended for databases and media; microSD is fine for light services (see [boot from NVMe SSD on Raspberry Pi 5]
• Ports: 9443/TCP (UI, HTTPS). 8000/TCP optional (Edge agent).
Docker (IMPORTANT):Docker is an essential part of this setup. Check this Raspberry Pi Docker guide for installation and advanced usage.

Installing Portainer on Raspberry Pi

1. Run in terminal to complete the setup and install Portainer Raspberry Pi quickly (see the official [Portainer CE install guide for Linux]
# Persistent data volumedocker
 volume create portainer_data
# Run Portainer CE
docker run -d \
  --name portainer \
 --restart=always \
 -p 9443:9443 -p 8000:8000 \
 -v /var/run/docker.sock:/var/run/docker.sock \
 -v portainer_data:/data \
  portainer/portainer-ce:latest


2.Open https://<raspberr-pi_ip>:9443 in your browser.
On first run, set the admin password and choose the local Docker environment.

Portainer first-time installation page with admin user and password setup form — create Portainer admin on Raspberry Pi

3.Configuring Environments (Endpoints) in Portainer: An environment (previously “endpoint”) is a compute target Portainer manages:
4. An environment (previously ‘endpoint’) is a compute target Portainer manages, which is especially useful for Portainer Docker Raspberry Pi setups.
Local Docker (the Docker host where Portainer runs).
Remote Docker via Agent (Portainer Agent on the target; inbound TCP 9001).
Edge Agent (outbound-only, NAT/firewall friendly; Portainer listens on 8000).

Portainer Quick Setup page showing Docker Standalone environment options — connect Raspberry Pi to Docker via Socket in Portainer

1) Local Docker (on the same Rasoberry Pi)

When you deployed Portainer with -v /var/run/docker.sock:/var/run/docker.sock, the Local environment is auto-created.
Verify:
In Environments, you should see local with a green status.
• If missing, go to EnvironmentsAdd environmentDocker and choose Local.

Portainer Environments page showing local Docker endpoint status on Raspberry Pi

Best practice:
• Restrict access to admin/team leads only (RBAC) since it exposes the host Docker socket.

2) Remote Docker via Portainer Agent (LAN/WAN with open port)

Use this when Portainer can reach the remote host on TCP 9001.
On the remote Raspberry Pi (target):
docker run -d \
  --name portainer_agent \
 --restart=always \
 -p 9001:9001 \
 -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/lib/docker/volumes:/var/lib/docker/volumes \
  portainer/agent:latest

In Portainer (server UI):
Environments → Add environment → Docker standalone → Agent
Name: e.g., pi-gateway-01
URL: tcp://<remote-ip>:9001
• Assign to a Group and Tags (e.g., iot, edge, lab).
• Save
Firewall/Network:
• Open 9001/TCP on the remote host.
•Static/DHCP-reserved IP recommended.

3) Remote Docker via Edge Agent (behind NAT/firewall)

Use this when you can’t open inbound ports. The Edge Agent dials out to your Portainer server.
Prereqs on the Portainer server:
• Expose 8000/TCP (we already mapped -p 8000:8000 when running Portainer). In Portainer (server UI):
Environments → Add environment → Edge Agent
• Choose Docker standalone.
• Set a Name, Group, Tags.
• Portainer generates Edge ID/Key and a ready-to-run command.

On the remote Raspberry Pi (target):
Use the command Portainer provides:
docker run -d \
  --name portainer_edge_agent \
  --restart=always \
  -v/var/run/docker.sock:/var/run/docker.sock \
  -v /var/lib/docker/volumes:/var/lib/docker/volumes \ -e EDGE=1 \
  -e EDGE_ID=<edge_id_from_portainer> \
  -e EDGE_KEY=<edge_key_from_portainer> \
  -e CAP_HOST_MANAGEMENT=1 \
   portainer/agent:latest
Here’s a concise, field-ready section you can paste into your guide. Wording is original and written from an IoT practitioner’s perspective.

Managing Containers & Workloads with Portainer (GUI) on Raspberry Pi

Stacks — Deploying Docker Compose Applications

Docker Compose Raspberry Pi stacks are easy to deploy with Portainer — perfect for multi-container applications.

Portainer Stack details page showing Docker Compose file with Mosquitto and Node-RED services on Raspberry Pi

When to use: multi-container apps (e.g., Mosquitto + Node-RED + InfluxDB + Grafana), services that share networks/volumes, or anything you want ver-sioned as a Compose file.
How (UI flow):
    1. Stacks → Add stack → pick Web editor (paste YAML) or Git repository (pin to a tag/commit).
    2. Environment variables: define secrets/credentials via Env or reference Secrets/Configs if you use them.
    3. Volumes: map to host paths like /srv/docker/<app>/... (keeps backups tidy).
    4. Networks: either let Portainer create one per stack or attach to a shared reverse-proxy network.
    5. Deploy the stack, then open Logs and Health for first-run checks.

Example (IoT mini-stack)

Portainer Containers page showing running Mosquitto and Node-RED containers on Raspberry Pi

services:
  mosquitto: image: eclipse-mosquitto:2.0
    restart: unless-stopped
     ports: ["1883:1883"]
    volumes: - /srv/docker/mosquitto/config:/mosquitto/config:ro
      - /srv/docker/mosquitto/data:/mosquitto/data
      - /srv/docker/mosquitto/log:/mosquitto/log
    healthcheck:
      test: ["CMD-SHELL", "nc -z localhost 1883 || exit 1"]
      interval: 15s
      retries: 5

nodered:
 image: nodered/node-red:latest
 depends_on: [mosquitto]
    restart: unless-stopped environment:
      - TZ=America/Argentina/Cordoba
      - NODE_RED_ENABLE_SAFE_MODE=false
     ports: ["1880:1880"]
     volumes: - /srv/docker/nodered:/data
     healthcheck:
     test: ["CMD", "wget", "-qO-", "http://localhost:1880"]
     interval: 30s
     retries: 5

networks:
  default:
    name: iot_core_net
    driver: bridge

Containers — Creating & Managing Individual Containers

When to use: single-service utilities (Pi-hole, Uptime Kuma, Zigbee2MQTT), quick tests, or one-off tools.

How (UI flow):
1. Containers → Add container
2. Image: specify full name and tag; optionally set Registry creds.
3. Runtime: command/entrypoint, Env (TZ, PUID/PGID), Devices (e.g., /dev/ttyUSB0 for radios), Capabilities (drop all; add only what’s needed).
4. Ports: publish only what you must; prefer a reverse proxy for external access.
5. Resources: set CPU/RAM limits; small Pis benefit from explicit ceilings.
6. Restart policy: unless-stopped for appliances; avoid always during debugging.

Daily ops:
Logs for quick triage, Console/Exec for shells inside the container.
Duplicate/Edit to roll minor changes without touching the stack.
Recreate with “pull latest image” when updating a pinned tag.

Volumes — Data Persistence & Mounting Options

Why it matters: SD cards wear quickly; databases and brokers need durable storage.

Portainer Volumes page showing local volume portainer_data mounted on Raspberry Pi

Options & guidance:
Bind mounts (recommended for IoT): map explicit paths, e.g., /srv/docker/mosquitto:/mosquitto
Easy to back up with tar or rsync; transparent layout.
Named volumes: fine for general use; less obvious where data lives on the host.
Read-only mounts: mount configs RO; keep only write-heavy paths RW.
Permissions: align PUID/PGID with host folder ownership to avoid per-mission loops.
Media & DBs: put time-series (InfluxDB), SQLite, and object stores on SSD/NVMe.
Backups: snapshot /srv/docker/<app> and your Compose repo together; test restores quarterly.

Networks — Container Networking & Communication

Design goals: predictable service discovery, minimal port exposure, and clean separation between stacks.

Portainer Networks page showing bridge, host, and custom stack networks on Raspberry Pi

Patterns that work:
Bridge per stack: default, keeps services isolated and lets you reach peers by service name (mqtt, nodered).
Shared “proxy” network: attach web-apps to a common network con-sumed by your reverse proxy.
Host network (use sparingly): only when you truly need broad-cast/multicast (mDNS/UPnP) or strict port fidelity. Be mindful of port con-flicts.
macvlan (advanced): give a container its own LAN IP (useful for legacy gear); remember the host can’t talk to macvlan by default—add a macvlan shim if needed.
DNS & discovery: inside the same network, use service names, not IPs. Outside, front everything with the proxy and a single TLS entrypoint.

Backups & Updates

Backups & Updates (IoT-grade practice)

Design for recovery first: if a Pi dies, you should be able to rebuild Docker, restore data, redeploy stacks, and be back in service fast. This section gives you a clear, repeatable workflow,and be back in service fast, thanks to simple Portainer backup and restore methods.

What to back up

Portainer state: portainer_data volume.
App data: bind mounts under /srv/docker/<app> and any named volumes (DBs, MQTT, flows).
Configuration: your Git repo with compose.yml, .env, and secrets (stored as files, not hard-coded).

Backing up bind mounts (configs, flows)

Bind mounts are just folders—use rsync for efficient copies.
sync to an external drive or NAS mount at /backups
sudo rsync -aHAX --delete --numeric-ids /srv/docker/ /backups/srv-docker/

Named volumes (databases, Portainer)

Archive with a helper container:
# Backup a named volume to /srv/backups docker run --rm \
  -v mydb:/from \
  -v /srv/backups:/to \、busybox sh -c 'cd /from && tar -czf
/to/mydb_$(date +%F).tgz .'
# Backup Portainer state docker run --rm \
  -v portainer_data:/from \
  -v /srv/backups:/to \ 
   busybox sh -c 'cd /from && tar -czf /to/portainer_$(date +%F).tgz .'

Monitoring & Troubleshooting

UI loads but environments show red
Likely: Agent unreachable (9001 blocked) or Edge tunnel failing (8000 blocked, proxy WS not forwarded).
Fix: Open required ports; for Edge, allow outbound to server’s 8000/9443 and enable WebSocket pass-through on proxy.
“Unauthorized” or frequent logouts
Likely: Cookie/domain mismatch or proxy rewriting headers.
Fix: Serve Portainer on a stable FQDN; ensure proxy preserves Authorization and Upgrade headers.
Edge agent stuck “awaiting tunnel”
Likely: Wrong Edge key/ID or server 8000 not reachable via the agent’s egress path.
Fix: Rotate Edge key in UI, redeploy the provided command on the device; verify egress to 8000/9443.
Slow UI / timeouts
Likely: Disk I/O contention or exhausted RAM on Pi.
Fix: Move data to SSD/NVMe, reduce simultaneous pulls, add swap (zram), pin images to known-good tags.
After upgrade, UI won’t start
Likely: Incomplete image pull or incompatible flags.
Fix: docker pull portainer/portainer-ce:latest, then recreate container with the same portainer_data volume.
RBAC/Password issues
Fix: Use the UI to reset passwords and review team access. If fully locked out, stop Portainer, back up portainer_data, and consult a controlled recovery (last resort: rebuild + restore).

Safe restart & update of Portainer

# Pull image, stop, remove, run (keeps state in portainer_data)
docker pull portainer/portainer-ce:latest
docker stop portainer && docker rm portainer

docker run -d --name portainer --restart=always \
  -p 9443:9443 -p 8000:8000 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
   portainer/portainer-ce:latest

Add a basic healthcheck (optional, via Compose)

services:
  portainer:
    image: portainer/portainer-ce:latest
    ports: ["9443:9443","8000:8000"] volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    restart: unless-stopped
     healthcheck: test: ["CMD-SHELL","nc -z localhost 9443 || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 5
volumes:
  portainer_data:

Conclusion

This Portainer Raspberry Pi guide shows how Portainer transforms the way you manage Docker containers on a Raspberry Pi, making complex tasks simple through an intuitive web interface.Portainer transforms the way you manage Docker containers on a Raspber-ry Pi, making complex tasks simple through an intuitive web interface. From deploying stacks and managing volumes to enhancing security and performing backups, it provides a complete toolkit for homelab and IoT enthusiasts. By combining Portainer with the flex-ibility of Raspberry Pi, you gain a lightweight yet powerful platform to experiment, learn, and build reliable services. With the right setup and best practices, your Raspberry Pi can become a stable, efficient, and secure container host for a wide range of projects.

Back to News Raspberry Pi Grafana: Complete Installation, Setup, and Dashboard Guide