Manage Docker with Portainer Web UI on VPS

Manage Docker with Portainer Web UI on VPS

June 2026 · 6 min read

Portainer CE is a Web UI for managing Docker that displays containers, images, volumes and networks all on a single page without needing to type long Docker commands every time. You can start/stop/restart containers, view logs, access shells and deploy stacks directly through your browser.

Install Portainer with Docker

# Create a volume to store Portainer data
docker volume create portainer_data

# Install Portainer CE
docker run -d \
  --name portainer \
  --restart unless-stopped \
  -p 8000:8000 \
  -p 9443:9443 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer-ce:latest

# Check if it is running
docker ps | grep portainer

Set Up Nginx Reverse Proxy for Portainer

sudo nano /etc/nginx/sites-available/portainer

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_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }
}

First Login and Admin Setup

# Open https://portainer.yourdomain.com
# or https://YOUR_VPS_IP:9443

# First time you must set the admin password within 5 minutes
# If time expires, reset with:
docker exec -it portainer /bin/sh
reset-password

Deploy Stacks via Portainer

# Go to Stacks > Add Stack
# Enter stack name and docker-compose.yml content
# Click Deploy the stack

# Example compose to paste in Portainer:
version: "3.8"
services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"
    volumes:
      - ./html:/usr/share/nginx/html
Tip: Use Portainer Templates (App Templates) to deploy popular apps like WordPress, Grafana, Nextcloud with just one click without writing compose files yourself

Manage Multiple Servers

# Install Portainer Agent on servers you want to manage
docker run -d \
  --name portainer_agent \
  --restart always \
  -p 9001:9001 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /var/lib/docker/volumes:/var/lib/docker/volumes \
  portainer/agent:latest

# Add server in Portainer:
# Settings > Environments > Add environment > Agent
# Enter the agent server IP:9001

Security: Restrict Permissions and Enable HTTPS

Portainer controls the entire Docker daemon = equivalent to root. If it gets compromised, everything is lost. You must lock it down:

# Restrict UI to office IP only with UFW
sudo ufw allow from 203.0.113.0/24 to any port 9443 proto tcp
sudo ufw deny 9443
Tip: If you use Portainer only occasionally for viewing/managing, keep the container stopped and run docker start portainer only when needed to greatly reduce the attack surface

Verify Portainer is Working Correctly

# Check container
docker ps | grep portainer

# Check port
ss -tlnp | grep 9443

# View logs
docker logs portainer -f

# Test API
curl -k https://localhost:9443/api/status
Tip: Enable Portainer Edge Agent to manage servers behind firewalls without opening any inbound ports. Perfect for servers in private networks

Common Issues & Troubleshooting

Cannot reset Portainer admin password (recreated container)

The portainer_data volume still holds the old data, you must delete the volume as well:

docker stop portainer && docker rm portainer
docker volume rm portainer_data
docker volume create portainer_data
# Then reinstall

Containers in Portainer disappear after VPS restart

Containers created through Portainer don't have a restart policy set, you must always set restart=unless-stopped:

# Fix in Portainer: Container > Restart policies > Unless Stopped
# Or via command:
docker update --restart unless-stopped container_name

Portainer shows "cannot connect to Docker daemon"

The Docker socket path is wrong or permissions are incorrect:

ls -la /var/run/docker.sock
# If socket doesn't exist, check Docker service
sudo systemctl status docker
sudo systemctl start docker

Frequently Asked Questions

Is Portainer CE free?

Portainer CE (Community Edition) is completely free and supports Docker standalone and Docker Swarm. Portainer Business (paid) adds LDAP, RBAC and audit logs for large organizations

Does Portainer support Kubernetes?

Portainer Business has full Kubernetes support. Portainer CE has basic Kubernetes support — you can manage namespaces, deployments and services through the Web UI but with fewer features

Is Portainer secure? Should I expose the port publicly?

You should protect it with Nginx + SSL and not expose port 9443 directly. For single-user setups, it's recommended to access it via SSH tunnel instead: ssh -L 9443:localhost:9443 user@vps