Managing Docker stacks with Portainer Business and GitOps
Deploy Portainer Business Edition for free on up to 3 nodes and wire GitHub webhooks to automate Docker Compose stack updates on a homelab.
Managing a growing homelab over SSH and manual
docker compose up -dcommands gets tedious fast. Using Portainer’s Take 3 Nodes Free license, you can run Portainer Business Edition (EE) at zero cost and wire a private GitHub repository (macmini-gitops-infra) to webhook-driven GitOps stack deployments.
Why Portainer Business Edition over CE
Most people default to Portainer Community Edition (CE) on a homelab because it’s open source. What many miss is that Portainer offers its commercial Business Edition (EE) permanently free for up to three nodes under the Take 3 Nodes Free program for personal homelabs, students, and small setups.
| Feature | Portainer Community (CE) | Portainer Business (EE, 3 Nodes Free) |
|---|---|---|
| License cost | Open source (free) | Free forever up to 3 nodes |
| Git webhook auto-deploy | Polling only (5-minute interval) or limited | Native instant webhook redeployment |
| Git credentials & access | Basic PAT auth | Granular saved credentials and branch controls |
| Activity logs (audit trail) | Not included | Tracks every container action and exec session |
| Registry management | Basic registry login | Private registry caching and extra controls |
| RBAC | Simple admin/user split | Role-based team and user permissions |
A personal Mac mini or small homelab cluster rarely exceeds three nodes, so you get every enterprise feature for $0. For real GitOps—where pushing a compose.yaml edit triggers a stack update in seconds instead of waiting on a 5-minute polling loop—EE’s native webhook support is the main reason to start with it.
When not to use Portainer: If you already manage your entire server declaratively with Ansible, NixOS, or Kubernetes (k3s + ArgoCD), adding Portainer introduces a second control plane that can drift from your IaC state. It shines when you want Docker Compose simplicity with a visual UI and lightweight GitOps.
GitOps deployment architecture
When I commit a change to compose.yaml and push to GitHub, a webhook hits Portainer through Nginx Proxy Manager, and Portainer pulls the latest commit and reconciles the stack over the host Docker socket:
flowchart TD
subgraph LocalDev["Developer Workflow"]
Dev["Local Machine<br/>(MacBook / PC)"]
GitRepo["Private GitHub Repo<br/>(macmini-gitops-infra)"]
end
subgraph HomelabHost["Homelab Host (Mac mini / Linux)"]
DockerSock["Docker UNIX Socket<br/>(/var/run/docker.sock)"]
subgraph Management["Management Layer"]
Portainer["Portainer Business EE<br/>(HTTP: 9000 / HTTPS: 9443)"]
PortainerVol[("portainer_data Volume")]
Portainer --- PortainerVol
end
subgraph Ingress["Ingress Proxy"]
NPM["Nginx Proxy Manager<br/>(portainer.namju.kim)"]
end
subgraph Stacks["GitOps-Managed Stacks"]
Stack1["Monitoring (Prometheus, Grafana)"]
Stack2["Storage (MinIO, MariaDB, Redis)"]
Stack3["Automation (n8n, Uptime Kuma)"]
end
end
Browser["Admin Browser"] -->|"HTTPS UI"| NPM
NPM -->|"Proxy + WebSocket"| Portainer
Dev -->|"1. git push"| GitRepo
GitRepo -->|"2. Webhook POST"| NPM
Portainer -->|"3. Pull & reconcile"| DockerSock
DockerSock -->|"4. Rolling update"| Stack1
DockerSock --> Stack2
DockerSock --> Stack3
Step 1: Claim the 3 Nodes Free license
Grab your license key before spinning up the container—it takes about a minute:
- Open Portainer’s Take 3 Nodes Free page.
- Submit your name and email address.
- Copy the 25-character license key (
XXXX-XXXX-XXXX-...) from your inbox and store it in your password manager.
Step 2: Deploy Portainer Business with Docker Compose
Start directly with the portainer/portainer-ee:latest image rather than migrating from CE later.
Write compose.yaml
Create a management stack directory (for example, ~/homelab/portainer) and add compose.yaml:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# compose.yaml (Portainer Business EE stack)
name: homelab-management
services:
portainer:
image: portainer/portainer-ee:latest
container_name: portainer
restart: unless-stopped
security_opt:
- no-new-privileges:true
ports:
- "127.0.0.1:9000:9000" # Bind to loopback only (block direct LAN/WAN exposure)
- "127.0.0.1:9443:9443" # Optional direct HTTPS port
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:rw # Host Docker daemon socket
- portainer_data:/data # Persist users, stacks, and EE license
networks:
- npm-network # Shared bridge with Nginx Proxy Manager
volumes:
portainer_data:
name: portainer_data
networks:
npm-network:
external: true
Binding to
0.0.0.0:9000exposes the unencrypted Portainer login screen to every device on your LAN (and the internet if misconfigured). Always bind to127.0.0.1and route external access strictly through your TLS reverse proxy.
Start the container and activate the license
1
docker compose up -d
5-minute initialization timeout: Portainer locks its setup screen if you don’t create the initial admin user within 5 minutes of first boot. If you hit that timeout, run
docker restart portainerand reload the page.
- Access Portainer via your reverse proxy (or SSH port-forward
ssh -L 9000:127.0.0.1:9000 user@homelaband openhttp://localhost:9000). - Create the
adminaccount with a strong password. - On the Submit License screen, paste your 3 Nodes Free key to unlock all Business Edition features immediately.
Step 3: Put Portainer behind Nginx Proxy Manager
If you already followed my Cloudflare DDNS and Nginx Proxy Manager wildcard SSL setup, exposing Portainer at https://portainer.namju.kim takes less than two minutes.
In the NPM admin UI (http://<homelab-ip>:81), click Hosts -> Proxy Hosts -> Add Proxy Host:
- Details tab:
- Domain Names:
portainer.namju.kim - Scheme:
http - Forward Hostname / IP:
portainer(resolved overnpm-network) - Forward Port:
9000 - Block Common Exploits: ON
- Websockets Support: ON
- Domain Names:
- SSL tab:
- SSL Certificate: Your
*.namju.kimwildcard certificate - Force SSL: ON
- HTTP/2 Support: ON
- HSTS Enabled: ON
- SSL Certificate: Your
Portainer’s container exec terminal (
docker exec) and live log streaming run over WebSockets. If Websockets Support is off, opening a container shell drops the connection immediately.
Step 4: Connect a private GitHub repo and webhook
With Portainer running behind HTTPS, you can move your stack definitions into a private Git repository so every infrastructure change is versioned and auditable.
Issue a fine-grained GitHub PAT
Create a read-only token scoped strictly to your homelab repository:
- In GitHub, go to Settings -> Developer Settings -> Personal Access Tokens -> Fine-grained tokens.
- Set the scope:
- Repository access:
Only select repositories->macmini-gitops-infra - Repository permissions:
Contents-> Read-only
- Repository access:
- Generate and copy the token (
github_pat_xxxx...).
Create a Git-backed stack in Portainer
- In Portainer, open Stacks -> Add stack.
- Enter a stack Name (for example,
homelab-storage) and pick Repository as the build method. - Fill in the repository settings:
- Repository URL:
https://github.com/<your-username>/macmini-gitops-infra.git - Repository reference:
refs/heads/main - Compose path:
stacks/storage/compose.yaml - Authentication: ON -> enter your GitHub username and fine-grained PAT
- Repository URL:
- Enable GitOps updates:
- Automatic updates: ON
- Mechanism: Webhook
- Copy the generated Webhook URL:
1
https://portainer.namju.kim/api/stacks/webhooks/xxxx-xxxx-xxxx
- Click Deploy the stack.
Register the webhook in GitHub
- Open
macmini-gitops-infraon GitHub and go to Settings -> Webhooks -> Add webhook. - Payload URL: Paste the Portainer Webhook URL.
- Content type:
application/json. - Which events:
Just the push event. - Click Add webhook.
Now, whenever you edit compose.yaml locally and run git push origin main, GitHub fires a POST request to Portainer, which pulls the commit and redeploys the affected containers in roughly 5 seconds.
Hardening the Docker socket and checklist
Mounting /var/run/docker.sock gives Portainer root-equivalent control over the Docker host, so treat the UI like SSH root access.
Audit changes with Activity Logs
Open Activity Logs in Portainer Business’s sidebar to inspect every stack deployment, container restart, environment variable change, and web console session down to the second. When something breaks on a homelab, this audit log tells you immediately whether a webhook push or a manual edit caused it.
Restrict UI access with NPM Access Lists
You don’t need the Portainer web UI open to the entire public internet. Use Access Lists in Nginx Proxy Manager to restrict portainer.namju.kim to your home LAN (192.168.0.0/16) and private VPN subnet (such as Tailscale’s 100.64.0.0/10). Note that if you lock down the whole domain with an IP allowlist, GitHub’s webhook IPs will also be blocked—either allowlist GitHub’s webhook CIDR ranges for /api/stacks/webhooks/ in NPM’s Custom Nginx Configuration or fall back to polling if you prefer zero public ingress.
Pre-flight checklist
- Portainer runs
portainer/portainer-ee:latestwith the 3 Nodes Free license active andno-new-privileges:trueset. - Ports
9000and9443bind to127.0.0.1only; external traffic goes through NPM with WebSockets enabled. - GitHub fine-grained PAT is restricted to one repo with
Contents: Read-only. - A test
git pushtriggers a200 OKdelivery in GitHub Webhooks and updates the stack in Portainer. - Admin UI access is restricted via NPM Access Lists or VPN, while webhook delivery paths are verified.