Skip to Content

Portainer Docker Setup: The Complete Guide to Managing Containers Without the Headache

Learn how to install, configure, and use Portainer to manage your Docker containers through a clean web UI — no terminal required after setup.
Portainer setup guide

Portainer Docker Setup: The Complete Guide to Managing Containers Without the Headache

If you've spent more time than you'd like running docker ps, grepping logs, and trying to remember which port maps to what — Portainer is the fix. It's a lightweight web UI that sits on top of Docker and gives you full visibility and control over your containers, images, volumes, and networks. This guide walks you through a complete Portainer Docker setup from scratch.


Prerequisites

Before you start, make sure you have the following in place:

  • A Linux server or local machine (Ubuntu 20.04+ recommended)
  • Docker Engine installed and running (docker --version should return a result)
  • Docker Compose v2 (optional but recommended)
  • A user with sudo or docker group membership
  • Port 9443 (HTTPS) or 9000 (HTTP) open on your firewall

To confirm Docker is running:

docker --version
sudo systemctl status docker

What Is Portainer and Why Use It?

Portainer is an open-source container management platform. It wraps the Docker API in a clean, intuitive UI so you can manage your entire container infrastructure from a browser. It supports Docker standalone, Docker Swarm, and Kubernetes.

Key Features

  • Visual dashboard for containers, images, volumes, and networks
  • Deploy stacks using Docker Compose directly in the UI
  • Live container logs and console access
  • Role-based access control (in Portainer Business Edition)
  • Multi-environment support — manage remote Docker hosts from one place

The Community Edition (CE) is completely free and covers everything most developers and small teams need.


Installing Portainer: Step-by-Step

Option 1: Docker Run (Quickest)

The fastest way to get Portainer running is a single docker run command. This creates a persistent volume for Portainer's data and exposes the web UI on port 9443.

docker volume create portainer_data

docker run -d \
  -p 8000:8000 \
  -p 9443:9443 \
  --name portainer \
  --restart=always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer-ce:latest

Once it's running, open your browser and go to https://<your-server-ip>:9443. You'll be prompted to create an admin account on first launch.

Option 2: Docker Compose (Recommended for Production)

If you prefer managing services declaratively, use a Compose file. Create a directory and drop this in:

# docker-compose.yml
version: '3.8'

services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: always
    ports:
      - "9000:9000"
      - "9443:9443"
      - "8000:8000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data

volumes:
  portainer_data:

Then bring it up:

docker compose up -d

Initial Configuration and First Login

Creating the Admin Account

On first access, Portainer asks you to set a username and password. The default username is admin — change it to something less predictable if this instance is exposed to the internet.

After login, you'll land on the Home screen showing your connected environments. Select local to start managing your Docker host.

Connecting to a Remote Docker Host

Portainer can manage remote Docker engines via the Portainer Agent. On the remote host, run:

docker run -d \
  -p 9001:9001 \
  --name portainer_agent \
  --restart=always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /var/lib/docker/volumes:/var/lib/docker/volumes \
  portainer/agent:latest

Then in Portainer UI, go to Environments → Add Environment → Agent and enter the remote host's IP and port 9001.


Managing Containers, Stacks, and Images

Deploying a Stack from the UI

One of Portainer's best features is deploying Docker Compose stacks directly in the browser. Go to Stacks → Add Stack, give it a name, and paste your Compose config. Here's an example deploying a simple Nginx + app stack:

version: '3.8'

services:
  web:
    image: nginx:alpine
    ports:
      - "80:80"
    volumes:
      - ./html:/usr/share/nginx/html
    restart: unless-stopped

  app:
    image: node:18-alpine
    working_dir: /app
    volumes:
      - ./app:/app
    command: node server.js
    restart: unless-stopped

Click Deploy the stack and Portainer handles the rest. You can update, redeploy, or tear it down from the same screen.

Inspecting and Managing Containers

From Containers, you can:

  • Start, stop, restart, kill, or remove containers
  • Inspect environment variables, mounts, and network settings
  • View real-time logs
  • Open an interactive console (like docker exec -it but in the browser)

Pulling and Pruning Images

Under Images, you can pull new images by name/tag, view layer details, and prune unused images to reclaim disk space — all without touching the CLI.


Portainer Behind a Reverse Proxy (Nginx)

If you want Portainer accessible at a clean domain like portainer.yourdomain.com, put it behind Nginx. Here's a minimal config:

server {
    listen 80;
    server_name portainer.yourdomain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name portainer.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/portainer.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/portainer.yourdomain.com/privkey.pem;

    location / {
        proxy_pass https://localhost:9443;
        proxy_ssl_verify off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Reload Nginx after saving:

sudo nginx -t && sudo systemctl reload nginx

Tips, Gotchas, and Troubleshooting

Portainer UI Not Loading?

  • Check the container is actually running: docker ps | grep portainer
  • Check logs for errors: docker logs portainer
  • Make sure port 9443 is open: sudo ufw allow 9443/tcp
  • If using HTTP on port 9000, make sure you're not forcing HTTPS in your browser

Permission Denied on Docker Socket

If Portainer can't connect to the Docker socket, your user may not have the right permissions:

sudo usermod -aG docker $USER
newgrp docker

Updating Portainer

To update to the latest version without losing data:

docker stop portainer
docker rm portainer
docker pull portainer/portainer-ce:latest

# Then re-run your original docker run command
docker run -d \
  -p 8000:8000 \
  -p 9443:9443 \
  --name portainer \
  --restart=always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer-ce:latest

Your data volume is preserved — settings, stacks, and users all survive the update.

Pro Tips

  • Use environment variables in stacks — Portainer supports .env files in stack deployments so you're not hardcoding secrets.
  • Set up Webhooks — Portainer can auto-redeploy a stack when a new image is pushed, useful for lightweight CD pipelines.
  • Enable 2FA — Go to your account settings and turn on two-factor authentication, especially on internet-facing instances.
  • Use resource limits — When creating containers via Portainer, set CPU and memory limits under the Advanced settings to avoid noisy neighbor problems.

Wrapping Up

A solid Portainer Docker setup takes less than ten minutes but pays dividends every time you need to debug a container, roll back a deployment, or onboard a teammate who isn't comfortable with the CLI. It doesn't replace Docker knowledge — but it does remove a lot of the friction around day-to-day management.

Start with the quick docker run install, get comfortable with stacks and the container inspector, then layer on a reverse proxy and agent connections as your infrastructure grows.


Need Enterprise-Grade Container Infrastructure?

If you're running containers at scale and need help with architecture, security hardening, or managed DevOps — the sysbrix team can help. We work with teams on Docker, Kubernetes, and cloud-native infrastructure from day one through production.

Talk to Us →
Run n8n on Windows the Right Way: Complete WSL2 Setup Guide
Follow this step-by-step guide to get a fully functional n8n automation server running on Windows using WSL2 — no Docker Desktop required.