14 KiB
Portainer - Docker Management Platform
Table of Contents
- Overview
- What is Portainer?
- Why Use Portainer?
- How It Works
- Configuration in AI-Homelab
- Official Resources
- Educational Resources
- Docker Configuration
- Using Portainer
- Advanced Topics
- Troubleshooting
Overview
Category: Infrastructure Management
Docker Image: portainer/portainer-ce
Default Stack: infrastructure.yml
Web UI: https://portainer.${DOMAIN}
Authentication: Built-in (admin/password) + Authelia protection
Role: Secondary management tool (Dockge is primary)
What is Portainer?
Portainer is a comprehensive Docker and Kubernetes management platform with an intuitive web interface. It provides enterprise-grade features for managing containers, images, networks, volumes, and more across single hosts or entire clusters.
Key Features
- Full Docker Management: Containers, images, networks, volumes, stacks
- User Management: Multi-user support with role-based access control (RBAC)
- Kubernetes Support: Manage K8s clusters (Community Edition)
- App Templates: One-click deployment of popular applications
- Registry Management: Connect to Docker registries
- Resource Monitoring: CPU, memory, network usage
- Container Console: Web-based terminal access
- Webhooks: Automated deployments via webhooks
- Environment Management: Manage multiple Docker hosts
- Team Collaboration: Share environments with teams
Why Use Portainer?
- Backup Management Tool: When Dockge has issues
- Advanced Features: User management, registries, templates
- Detailed Information: More comprehensive stats and info
- Image Management: Better interface for managing images
- Network Visualization: See container networking
- Volume Management: Easy volume backup/restore
- Established Platform: Mature, well-documented, large community
- Enterprise Option: Can upgrade to Business Edition if needed
How It Works
User → Web Browser → Portainer UI
↓
Docker Socket
↓
Docker Engine
↓
All Docker Resources
(Containers, Images, Networks, Volumes)
Architecture
Portainer consists of:
- Portainer Server: Main application with web UI
- Docker Socket: Connection to Docker Engine
- Portainer Agent: Optional, for managing remote hosts
- Database: Stores configuration, users, settings
Configuration in AI-Homelab
Directory Structure
/opt/stacks/infrastructure/portainer/
└── data/ # Portainer database and config (auto-created)
Initial Setup
First Login:
- Access
https://portainer.yourdomain.com - Create admin account (username: admin)
- Choose "Docker" environment
- Select "Connect via Docker socket"
Environment Variables
# No environment variables typically needed
# Configuration done through Web UI
Official Resources
- Website: https://www.portainer.io
- Documentation: https://docs.portainer.io
- Community Edition: https://www.portainer.io/portainer-ce
- GitHub: https://github.com/portainer/portainer
- Docker Hub: https://hub.docker.com/r/portainer/portainer-ce
- Forum: https://community.portainer.io
- YouTube: https://www.youtube.com/c/portainerio
Educational Resources
Videos
- Portainer - Docker Management Made Easy (Techno Tim)
- Portainer Full Tutorial (NetworkChuck)
- Portainer vs Dockge Comparison
- Advanced Portainer Features (DB Tech)
Articles & Guides
- Portainer Official Documentation
- Getting Started with Portainer
- Portainer vs Dockge
- Docker Management Best Practices
Concepts to Learn
- Docker Management: Centralized control of Docker resources
- RBAC: Role-Based Access Control for teams
- Stacks: Docker Compose deployments via UI
- Templates: Pre-configured app deployments
- Registries: Docker image repositories
- Environments: Multiple Docker hosts managed together
- Agents: Remote Docker host management
Docker Configuration
Complete Service Definition
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- traefik-network
ports:
- "9443:9443" # HTTPS UI
- "8000:8000" # Edge agent (optional)
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /opt/stacks/infrastructure/portainer/data:/data
environment:
- TZ=America/New_York
labels:
- "traefik.enable=true"
- "traefik.http.routers.portainer.rule=Host(`portainer.${DOMAIN}`)"
- "traefik.http.routers.portainer.entrypoints=websecure"
- "traefik.http.routers.portainer.tls.certresolver=letsencrypt"
- "traefik.http.routers.portainer.middlewares=authelia@docker"
- "traefik.http.services.portainer.loadbalancer.server.port=9443"
- "traefik.http.services.portainer.loadbalancer.server.scheme=https"
Important Notes
- Port 9443: HTTPS UI (Portainer uses self-signed cert internally)
- Docker Socket: Read-only mount recommended for security
- Data Volume: Stores all Portainer configuration
- Edge Agent Port: 8000 for remote agent connections (optional)
Using Portainer
Dashboard Overview
Home Dashboard Shows:
- Total containers (running, stopped)
- Total images
- Total volumes
- Total networks
- Stack count
- Resource usage (CPU, memory)
Container Management
View Containers:
- Home → Containers
- See all containers with status
- Quick actions: start, stop, restart, remove
Container Details:
- Logs (real-time and download)
- Stats (CPU, memory, network)
- Console (terminal access)
- Inspect (full container JSON)
- Recreate (update container)
Container Actions:
- Start/Stop/Restart: One-click control
- Logs: View stdout/stderr output
- Stats: Real-time resource usage
- Exec Console: Access container shell
- Duplicate: Create copy with same config
- Recreate: Pull new image and restart
Stack Management
Deploy Stack:
- Stacks → Add Stack
- Name your stack
- Choose method:
- Web editor (paste compose)
- Upload compose file
- Git repository
- Click "Deploy the stack"
Manage Existing Stacks:
- View all services in stack
- Edit compose configuration
- Stop/Start entire stack
- Remove stack (keep/delete volumes)
Image Management
Images View:
- All local images
- Size and tags
- Pull new images
- Remove unused images
- Build from Dockerfile
- Import/Export images
Common Operations:
Pull Image: Images → Pull → Enter image:tag
Remove Image: Images → Select → Remove
Build Image: Images → Build → Upload Dockerfile
Network Management
View Networks:
- All Docker networks
- Connected containers
- Network driver type
- Subnet information
Create Network:
- Networks → Add Network
- Name and driver (bridge, overlay)
- Configure subnet/gateway
- Attach containers
Volume Management
View Volumes:
- All Docker volumes
- Size and mount points
- Containers using volume
Volume Operations:
- Create new volumes
- Remove unused volumes
- Browse volume contents
- Backup/restore volumes
App Templates
Quick Deploy:
- App Templates
- Select application
- Configure settings
- Deploy
Popular Templates:
- WordPress, MySQL, Redis
- Nginx, Apache
- PostgreSQL, MongoDB
- And many more...
Advanced Topics
User Management
Create Users:
- Users → Add User
- Username and password
- Assign role
- Set team membership (if teams exist)
Roles:
- Administrator: Full access
- Operator: Manage containers, no settings
- User: Limited access to assigned resources
- Read-only: View only
Team Collaboration
Create Team:
- Teams → Add Team
- Name team
- Add members
- Assign resource access
Use Case:
- Family team: Access to media services
- Admin team: Full access
- Guest team: Limited access
Registry Management
Add Private Registry:
- Registries → Add Registry
- Choose type (Docker Hub, GitLab, custom)
- Enter credentials
- Test connection
Use Cases:
- Private Docker Hub repos
- GitHub Container Registry
- Self-hosted registry
- GitLab Registry
Webhooks
Automated Deployments:
- Select container/stack
- Create webhook
- Copy webhook URL
- Configure in CI/CD pipeline
Example:
# Trigger container update
curl -X POST https://portainer.domain.com/api/webhooks/abc123
Multiple Environments
Add Remote Docker Host:
- Environments → Add Environment
- Choose "Docker" or "Agent"
- Enter connection details
- Test and save
Agent Deployment:
portainer-agent:
image: portainer/agent:latest
ports:
- "9001:9001"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
Custom Templates
Create Template:
- App Templates → Custom Templates
- Add template
- Define compose configuration
- Set categories and logo
- Save
Resource Limits
Set container limits in Portainer UI:
- Edit container
- Resources & Runtime
- Set CPU/memory limits
- Apply changes
Troubleshooting
Can't Access Portainer
# Check if running
docker ps | grep portainer
# View logs
docker logs portainer
# Check port
curl -k https://localhost:9443
# Verify Traefik routing
docker logs traefik | grep portainer
Forgot Admin Password
# Stop Portainer
docker stop portainer
# Remove admin user from DB
docker run --rm -v portainer_data:/data portainer/portainer-ce \
--admin-password 'NewPassword123!'
# Or reset completely (deletes all data)
docker stop portainer
docker rm portainer
docker volume rm portainer_data
docker compose up -d portainer
Stacks Not Visible
# Portainer looks for compose files in specific location
# It doesn't automatically detect all stacks like Dockge
# Import existing stacks:
# Stacks → Add Stack → Web Editor → Paste compose content
Container Terminal Not Working
# Ensure container has shell
docker exec container-name which bash
# Check Portainer logs
docker logs portainer | grep console
# Try different shell
# In Portainer: Console → Command → /bin/sh
High Memory Usage
# Portainer uses more resources than Dockge
# Check stats
docker stats portainer
# If too high:
# - Close unused browser tabs
# - Restart Portainer
# - Reduce polling frequency (Settings)
Database Corruption
# Backup first
cp -r /opt/stacks/infrastructure/portainer/data /opt/backups/
# Stop and recreate
docker stop portainer
docker rm portainer
docker volume rm portainer_data
docker compose up -d portainer
Security Considerations
Best Practices
- Strong Admin Password: Use complex password
- Enable HTTPS: Always use SSL/TLS
- Use Authelia: Add extra authentication layer
- Limit Docker Socket: Use read-only when possible
- Regular Updates: Keep Portainer updated
- User Management: Create separate users, avoid sharing admin
- RBAC: Use role-based access for teams
- Audit Logs: Review activity logs regularly
- Network Isolation: Don't expose to internet without protection
- Backup Configuration: Regular backups of
/datavolume
Docker Socket Security
Risk: Full socket access = root on host
Mitigations:
- Use Docker Socket Proxy (see docker-proxy.md)
- Read-only mount when possible
- Limit user access to Portainer
- Monitor audit logs
- Use Authelia for additional authentication
Portainer vs Dockge
When to Use Portainer
- Need user management (teams, RBAC)
- Managing multiple Docker hosts
- Want app templates
- Need detailed image management
- Enterprise features required
- More established, proven platform
When to Use Dockge
- Simple stack management
- Direct file manipulation preferred
- Lighter resource usage
- Faster for compose operations
- Better terminal experience
- Cleaner, modern UI
AI-Homelab Approach
- Primary: Dockge (daily operations)
- Secondary: Portainer (backup, advanced features)
- Use Both: They complement each other
Tips & Tricks
Quick Container Recreate
To update a container with new image:
- Containers → Select container
- Click "Recreate"
- Check "Pull latest image"
- Click "Recreate"
Volume Backup
- Volumes → Select volume
- Export/Backup
- Download tar archive
- Store safely
Stack Migration
Export from one host, import to another:
- Select stack
- Copy compose content
- On new host: Add Stack → Paste
- Deploy
Environment Variables
Set globally for all stacks:
- Stacks → Select stack → Editor
- Environment variables section
- Add key=value pairs
- Update stack
Summary
Portainer is your backup Docker management platform. It provides:
- Comprehensive Docker management
- User and team collaboration
- Advanced features for complex setups
- Reliable, established platform
- Detailed resource monitoring
While Dockge is the primary tool for daily stack management, Portainer excels at:
- User management and RBAC
- Multiple environment management
- Detailed image and volume operations
- Template-based deployments
- Enterprise-grade features
Keep both running - they serve different purposes and complement each other well. Use Dockge for quick stack operations and Portainer for advanced features and user management.
Remember:
- Portainer is backup/secondary tool in AI-Homelab
- Different interface philosophy than Dockge
- More features, higher resource usage
- Excellent for multi-user scenarios
- Always protect with Authelia
- Regular backups of
/datavolume