Home Server › Containers

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 Docker stacks with Portainer Business and GitOps

Managing a growing homelab over SSH and manual docker compose up -d commands 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.

FeaturePortainer Community (CE)Portainer Business (EE, 3 Nodes Free)
License costOpen source (free)Free forever up to 3 nodes
Git webhook auto-deployPolling only (5-minute interval) or limitedNative instant webhook redeployment
Git credentials & accessBasic PAT authGranular saved credentials and branch controls
Activity logs (audit trail)Not includedTracks every container action and exec session
Registry managementBasic registry loginPrivate registry caching and extra controls
RBACSimple admin/user splitRole-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:

  1. Open Portainer’s Take 3 Nodes Free page.
  2. Submit your name and email address.
  3. 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:9000 exposes the unencrypted Portainer login screen to every device on your LAN (and the internet if misconfigured). Always bind to 127.0.0.1 and 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 portainer and reload the page.

  1. Access Portainer via your reverse proxy (or SSH port-forward ssh -L 9000:127.0.0.1:9000 user@homelab and open http://localhost:9000).
  2. Create the admin account with a strong password.
  3. 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:

  1. Details tab:
    • Domain Names: portainer.namju.kim
    • Scheme: http
    • Forward Hostname / IP: portainer (resolved over npm-network)
    • Forward Port: 9000
    • Block Common Exploits: ON
    • Websockets Support: ON
  2. SSL tab:
    • SSL Certificate: Your *.namju.kim wildcard certificate
    • Force SSL: ON
    • HTTP/2 Support: ON
    • HSTS Enabled: ON

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:

  1. In GitHub, go to Settings -> Developer Settings -> Personal Access Tokens -> Fine-grained tokens.
  2. Set the scope:
    • Repository access: Only select repositories -> macmini-gitops-infra
    • Repository permissions: Contents -> Read-only
  3. Generate and copy the token (github_pat_xxxx...).

Create a Git-backed stack in Portainer

  1. In Portainer, open Stacks -> Add stack.
  2. Enter a stack Name (for example, homelab-storage) and pick Repository as the build method.
  3. 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
  4. Enable GitOps updates:
    • Automatic updates: ON
    • Mechanism: Webhook
    • Copy the generated Webhook URL:
      1
      
      https://portainer.namju.kim/api/stacks/webhooks/xxxx-xxxx-xxxx
      
  5. Click Deploy the stack.

Register the webhook in GitHub

  1. Open macmini-gitops-infra on GitHub and go to Settings -> Webhooks -> Add webhook.
  2. Payload URL: Paste the Portainer Webhook URL.
  3. Content type: application/json.
  4. Which events: Just the push event.
  5. 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:latest with the 3 Nodes Free license active and no-new-privileges:true set.
  • Ports 9000 and 9443 bind to 127.0.0.1 only; external traffic goes through NPM with WebSockets enabled.
  • GitHub fine-grained PAT is restricted to one repo with Contents: Read-only.
  • A test git push triggers a 200 OK delivery 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.
This post is licensed under CC BY 4.0 by the author.