A lightweight Docker container that provides a simple web interface for safely shutting down your Raspberry Pi. Perfect for headless, battery-powered setups where you need a graceful shutdown option.
- 🌐 Clean, responsive web interface
- ✅ Checkbox confirmation to prevent accidental shutdowns
- 🔒 Secure sudo configuration (only shutdown command allowed)
- 🏥 Built-in health check endpoint
- 📱 Mobile-friendly design
- 🎨 Modern, intuitive UI
IMPORTANT: Build directly on the Raspberry Pi to ensure correct ARM architecture.
# On your Raspberry Pi
cd /path/to/ShutdownContainer
docker build -t barrybahrami/private:pi-shutdown .docker run -d \
--name pi-shutdown \
--restart unless-stopped \
--privileged \
--pid=host \
-p 80:8080 \
barrybahrami/private:pi-shutdownImportant flags:
--privileged: Allows container to access host system--pid=host: Shares host's PID namespace (required for nsenter to work)-p 80:8080: Maps host port 80 to container port 8080
If you want to save the image to Docker Hub:
docker login
docker push barrybahrami/private:pi-shutdownOpen your browser and navigate to:
http://<raspberry-pi-ip>(from any device on the network)
- Check the confirmation checkbox
- Click the "Shutdown System" button
- The system will safely shutdown
docker logs -f pi-shutdowndocker stop pi-shutdowndocker start pi-shutdowndocker restart pi-shutdowndocker rm pi-shutdowndocker pull <your-dockerhub-username>/pi-shutdown:latest
docker stop pi-shutdown
docker rm pi-shutdown
# Then run the Step 3 command again- Web Interface: Flask serves a single-page application with HTML/CSS/JavaScript
- Confirmation: User must check a box before the shutdown button becomes active
- Shutdown Request: When clicked, sends a POST request to
/shutdownendpoint - System Shutdown: Container executes
sudo shutdown -h nowon the host system - Privileged Mode: Container runs in privileged mode with access to host's shutdown command
- The container runs in privileged mode to access the host's shutdown command
- The internal user has limited sudo access (only for the shutdown command)
- The web interface has no authentication - ensure your network is secure
- Consider adding authentication if exposing to untrusted networks
- Runs on port 80 - accessible at
http://<pi-ip>without specifying a port
docker logs pi-shutdown- Ensure the container is running in privileged mode
- Check that
/sbin/shutdownis mounted correctly - Verify sudo permissions inside the container:
docker exec -it pi-shutdown sudo -l
- Check if the container is running:
docker ps - Verify port 80 is not blocked by firewall
- Try accessing from the Pi itself:
curl http://localhost:8080/health
IMPORTANT: Before deploying to your Raspberry Pi, test on another machine first!
The shutdown command will actually shutdown the host machine, so make sure you're ready for that.
- Docker
- Docker Compose
- Raspberry Pi OS / Ubuntu (or any Linux distribution)
- Sudo access for the shutdown command
Free to use for any purpose.