Setting up a Raspberry Pi 4 infokiosk system with Docker and Portainer involves several steps. Below is a detailed guide to help you configure both Pi 1 (server + kiosk) and Pi 2 (kiosk-only). We'll also create a simple web-based control panel to manage URLs and timeouts.
Step 1: Setting Up Pi 1 (Server + Kiosk)
1.1 Install Raspberry Pi OS
- Download the latest Raspberry Pi OS (64-bit recommended) from the official website.
- Flash the image onto an SD card using tools like Raspberry Pi Imager or Balena Etcher.
- Insert the SD card into Pi 1, connect peripherals (keyboard, mouse, monitor), and power it on.
- Complete the initial setup:
- Set hostname to
infokiosk1.
- Enable SSH during setup or run
sudo raspi-config later to enable it.
- Connect to Wi-Fi or Ethernet.
1.2 Update the System
Run the following commands to update the system:
sudo apt update && sudo apt upgrade -y
1.3 Install Docker
- Install Docker using the convenience script:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
- Add the
pi user to the docker group:
sudo usermod -aG docker pi
- Log out and log back in for the changes to take effect.
1.4 Install Portainer
- Pull the Portainer CE image:
docker pull portainer/portainer-ce
- Run Portainer as a container:
docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
- Access Portainer by navigating to
http://<Pi1-IP>:9000 in your browser. Set up an admin account when prompted.
1.5 Create a Web-Based Control Panel
We’ll use a simple Flask app to manage URLs and timeouts. This app will serve as the backend for controlling the kiosks.
- Install Python dependencies:
sudo apt install python3-pip -y
pip3 install flask
- Create a directory for the Flask app:
mkdir ~/kiosk-control
cd ~/kiosk-control
- Create a file named
app.py with the following content:
from flask import Flask, request, jsonify
app = Flask(__name__)
# Default settings
settings = {
"url": "http://example.com",
"timeout": 30
}
@app.route('/settings', methods=['GET'])
def get_settings():
return jsonify(settings)
@app.route('/settings', methods=['POST'])
def update_settings():
global settings
data = request.json
if 'url' in data:
settings['url'] = data['url']
if 'timeout' in data:
settings['timeout'] = data['timeout']
return jsonify({"message": "Settings updated", "settings": settings})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
- Run the Flask app:
python3 app.py
- Test the API by sending requests:
- GET current settings:
curl http://<Pi1-IP>:5000/settings
- POST new settings:
curl -X POST -H "Content-Type: application/json" -d '{"url": "http://newurl.com", "timeout": 60}' http://<Pi1-IP>:5000/settings
1.6 Configure Pi 1 as a Kiosk
- Install Chromium:
sudo apt install chromium-browser -y
- Create a script to launch Chromium in kiosk mode:
nano ~/start-kiosk.sh
Add the following content:
#!/bin/bash
URL=$(curl -s http://localhost:5000/settings | jq -r '.url')
TIMEOUT=$(curl -s http://localhost:5000/settings | jq -r '.timeout')
while true; do
chromium-browser --noerrdialogs --disable-infobars --kiosk $URL
sleep $TIMEOUT
done
- Make the script executable:
chmod +x ~/start-kiosk.sh
- Install
jq for JSON parsing:
sudo apt install jq -y
- Add the script to autostart:
mkdir -p ~/.config/autostart
nano ~/.config/autostart/kiosk.desktop
Add the following content:
[Desktop Entry]
Type=Application
Exec=/home/pi/start-kiosk.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Kiosk Mode
Comment=Start Kiosk Mode
Step 2: Setting Up Pi 2 (Kiosk-Only)
2.1 Install Raspberry Pi OS
Follow the same steps as in 1.1 but set the hostname to infokiosk2.
2.2 Update the System
Run the same update commands as in 1.2.
2.3 Install Docker
Repeat the Docker installation steps from 1.3.
2.4 Configure Pi 2 as a Kiosk
- Install Chromium:
sudo apt install chromium-browser -y
- Create a script to fetch settings from Pi 1 and launch Chromium:
nano ~/start-kiosk.sh
Add the following content:
#!/bin/bash
PI1_IP="<Pi1-IP>"
while true; do
URL=$(curl -s http://$PI1_IP:5000/settings | jq -r '.url')
TIMEOUT=$(curl -s http://$PI1_IP:5000/settings | jq -r '.timeout')
chromium-browser --noerrdialogs --disable-infobars --kiosk $URL
sleep $TIMEOUT
done
- Replace
<Pi1-IP> with the actual IP address of Pi 1.
- Make the script executable:
chmod +x ~/start-kiosk.sh
- Install
jq:
sudo apt install jq -y
- Add the script to autostart (same as in 1.6).
Final Notes
- Use Portainer to manage Docker containers on both Pis.
- Access the Flask API on Pi 1 to update URLs and timeouts dynamically.
- Ensure both Pis are on the same network for seamless communication.
If you encounter any issues or need further clarification, feel free to ask!