docker.recipes

Portainer Container Management

beginner

Complete Docker and Kubernetes management solution with beautiful web UI, user management, and multi-environment support.

Overview

Portainer is a universal container management platform that transforms complex Docker, Kubernetes, and Docker Swarm operations into an intuitive web-based interface. Originally created to democratize container management, Portainer eliminates the need for command-line expertise while providing enterprise-grade features like role-based access control, multi-environment management, and GitOps workflows. The platform has evolved from a simple Docker GUI into a comprehensive container orchestration solution trusted by both homelab enthusiasts and enterprise teams. This deployment combines Portainer CE with its companion agent to create a powerful management hub for your container infrastructure. The main Portainer service provides the web interface and core management capabilities, while the Portainer agent enables secure communication with remote Docker environments and edge devices. Together, they form a centralized control plane that can manage multiple Docker hosts, Swarm clusters, and Kubernetes environments from a single dashboard. This stack is ideal for teams transitioning from manual Docker management to a more structured approach, system administrators managing multiple hosts, and organizations seeking to provide controlled container access to developers without exposing underlying infrastructure. The combination offers visual stack deployment, template-based application installation, and comprehensive logging and monitoring capabilities that bridge the gap between simple container tools and complex enterprise platforms like Rancher.

Key Features

  • Multi-platform container orchestration supporting Docker, Docker Swarm, and Kubernetes clusters
  • Visual stack deployment with drag-and-drop Docker Compose editing and validation
  • Template marketplace with pre-configured applications and custom template support
  • Role-based access control with team management and environment-specific permissions
  • Edge agent deployment for managing remote locations and IoT devices
  • GitOps integration with automatic stack updates from Git repositories
  • Container registry management with support for private registries and image scanning
  • Real-time resource monitoring with container logs, stats, and performance metrics

Common Use Cases

  • 1Homelab management for self-hosted services and personal development environments
  • 2Small to medium team Docker environments requiring user access control and collaboration
  • 3Multi-site container deployments with centralized management across edge locations
  • 4Development teams needing visual container management without CLI complexity
  • 5Educational environments for teaching containerization and orchestration concepts
  • 6Rapid prototyping and testing with template-based application deployment
  • 7Legacy infrastructure modernization with gradual container adoption

Prerequisites

  • Docker Engine 20.10+ with Docker Compose plugin installed
  • Minimum 256MB RAM available for Portainer CE (512MB recommended for production)
  • Ports 9443 (HTTPS UI) and 8000 (tunnel server) available and accessible
  • Docker socket access permissions for container management operations
  • SSL/TLS certificates for production deployments (self-signed acceptable for development)
  • Network connectivity between Portainer server and any remote Docker hosts or agents

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 portainer:
3 image: portainer/portainer-ce:latest
4 ports:
5 - "9443:9443"
6 - "8000:8000"
7 volumes:
8 - /var/run/docker.sock:/var/run/docker.sock
9 - portainer_data:/data
10 restart: always
11 networks:
12 - portainer_net
13
14 portainer-agent:
15 image: portainer/agent:latest
16 volumes:
17 - /var/run/docker.sock:/var/run/docker.sock
18 - /var/lib/docker/volumes:/var/lib/docker/volumes
19 networks:
20 - portainer_net
21
22volumes:
23 portainer_data:
24
25networks:
26 portainer_net:

.env Template

.env
1# Portainer
2# Portainer at https://localhost:9443
3# Create admin account on first login

Usage Notes

  1. 1Portainer at https://localhost:9443
  2. 2Create admin on first access
  3. 3Manage Docker/Swarm/K8s
  4. 4Agent for remote environments
  5. 5Edge agent for edge devices

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

portainer
portainer:
  image: portainer/portainer-ce:latest
  ports:
    - "9443:9443"
    - "8000:8000"
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - portainer_data:/data
  restart: always
  networks:
    - portainer_net
portainer-agent
portainer-agent:
  image: portainer/agent:latest
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - /var/lib/docker/volumes:/var/lib/docker/volumes
  networks:
    - portainer_net

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 portainer:
5 image: portainer/portainer-ce:latest
6 ports:
7 - "9443:9443"
8 - "8000:8000"
9 volumes:
10 - /var/run/docker.sock:/var/run/docker.sock
11 - portainer_data:/data
12 restart: always
13 networks:
14 - portainer_net
15
16 portainer-agent:
17 image: portainer/agent:latest
18 volumes:
19 - /var/run/docker.sock:/var/run/docker.sock
20 - /var/lib/docker/volumes:/var/lib/docker/volumes
21 networks:
22 - portainer_net
23
24volumes:
25 portainer_data:
26
27networks:
28 portainer_net:
29EOF
30
31# 2. Create the .env file
32cat > .env << 'EOF'
33# Portainer
34# Portainer at https://localhost:9443
35# Create admin account on first login
36EOF
37
38# 3. Start the services
39docker compose up -d
40
41# 4. View logs
42docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/portainer-complete/run | bash

Troubleshooting

  • Cannot access Portainer UI after startup: Verify port 9443 is not blocked by firewall and container logs show 'Portainer started on :9443'
  • Docker socket permission denied errors: Add your user to docker group with 'usermod -aG docker $USER' and restart session
  • Agent connection fails with 'tunnel server unreachable': Ensure port 8000 is accessible from agent host and check network connectivity
  • Stack deployment fails with 'compose file invalid': Use Portainer's built-in validator or verify YAML syntax and indentation
  • High memory usage or slow performance: Increase container memory limits and consider using Portainer Business Edition for better resource optimization
  • Lost admin access after initial setup: Reset admin password by stopping container, removing portainer_data volume, and recreating stack

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space