Skip to main content
Back to Category

Docker Management with Portainer: Web-Based Container Control

Portainer CE installation, Docker and Kubernetes management, stack deployment, volume/network management, user authorization, webhook and GitOps integration.

Read time: 13 min Self-Hosting
portainerdockerkubernetesweb interfacecontainer managementself-hosting

Table of Contents

Docker Management with Portainer: Web-Based Container Control

Portainer is an open-source container management platform that lets you manage Docker and Kubernetes environments through a web browser. Without requiring command-line knowledge, you can easily start, stop containers, view logs, and deploy stacks.

What is Portainer CE?

Portainer Community Edition (CE) is free and open-source. Key features:

  • Container Management: Start, stop, restart, delete
  • Image Management: Pull, push, build, tag operations
  • Stack Deploy: Deploy Docker Compose files from the web interface
  • Volume/Network: Storage and network management
  • Log Viewing: Real-time container logs
  • Console Access: Connect to containers via web terminal
  • User Management: Role-based access control

Installation

Create Docker Volume

hljs bash
# Create volume to store Portainer data
docker volume create portainer_data

Install Portainer CE

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

After installation:

https://SERVER_IP:9443

On first login, you need to set an admin password. If you don't log in within 5 minutes, Portainer needs to be restarted for security reasons.

Installation with Docker Compose

hljs yaml
# portainer-compose.yml
version: '3.8'
services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: always
    ports:
      - "8000:8000"
      - "9443:9443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    security_opt:
      - no-new-privileges:true

volumes:
  portainer_data:
hljs bash
docker compose -f portainer-compose.yml up -d

Docker Socket Connection

Portainer communicates with the Docker daemon via /var/run/docker.sock. Access to this socket provides full control over Docker:

hljs bash
# Check socket permissions
ls -la /var/run/docker.sock
# srw-rw---- 1 root docker 0 ... /var/run/docker.sock

# Add user to docker group (if needed)
usermod -aG docker $USER

Access to the Docker socket is equivalent to root privileges. Run Portainer on trusted networks and use a strong password.

Deploying Stacks (Docker Compose)

Deploy Stack from Web Interface

  1. StacksAdd Stack
  2. Enter stack name
  3. Paste Docker Compose content or enter Git repository URL
  4. Add environment variables
  5. Click Deploy the stack
hljs yaml
# Example: WordPress Stack
version: '3.8'
services:
  wordpress:
    image: wordpress:latest
    restart: always
    ports:
      - "8080:80"
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: ${DB_USER}
      WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - wordpress_data:/var/www/html
    depends_on:
      - db

  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_DATABASE: wordpress
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
    volumes:
      - db_data:/var/lib/mysql

volumes:
  wordpress_data:
  db_data:

Deploy Stack from Git Repository

  1. Select Repository option when creating a stack
  2. Enter Git URL: https://github.com/user/repo
  3. Specify branch and compose file path
  4. Enable GitOps updates for automatic updates

Container Management

Container Operations

Operations available on containers from the Portainer interface:

hljs bash
# In Portainer interface:
# Containers → select container → Actions:
# - Start / Stop / Restart / Kill / Pause
# - Logs (real-time)
# - Console (web terminal)
# - Inspect (JSON details)
# - Stats (CPU, RAM, Network usage)

Web Terminal (Exec Console)

Open a terminal to a container from your web browser:

  1. Containers → Click on container name
  2. Console tab → Connect
  3. Select shell: /bin/bash or /bin/sh
hljs bash
# Commands you can run inside the container:
ls -la /app
cat /etc/nginx/nginx.conf
nginx -t
env | grep DATABASE

Image Management

hljs bash
# From Portainer interface:
# Images → Pull Image
# Registry: docker.io (default)
# Image: nginx:latest

# To add a custom registry:
# Registries → Add Registry
# URL: registry.example.com
# Enter username and password

Volume Management

hljs bash
# From Portainer interface:
# Volumes → Add Volume
# Name: myapp_data
# Driver: local

# Volume details:
# - Which containers are using it
# - Disk usage
# - Mount point: /var/lib/docker/volumes/myapp_data/_data

Network Management

hljs bash
# From Portainer interface:
# Networks → Add Network
# Name: myapp-network
# Driver: bridge
# Subnet: 172.20.0.0/16

# Connect containers to network:
# Container → Network → Join Network

User and Team Management

Creating Users

  1. SettingsUsersAdd User
  2. Set username and password
  3. Assign role: Administrator or Standard User

Creating Teams

hljs bash
# From Portainer interface:
# Settings → Teams → Add Team
# Team name: developers
# Add members: user1, user2

Environment Access Control

hljs bash
# Environments → Select Environment → Access Control
# Grant access to specific users or teams
# Role: Manager (full access) or Operator (limited)

Automatic Updates with Webhooks

hljs bash
# Create webhook for Stack or Service:
# Stack → Stack name → Webhooks
# Copy webhook URL

# Usage in GitHub Actions:
curl -X POST https://portainer.example.com/api/webhooks/WEBHOOK_TOKEN

# Usage in GitLab CI:
wget --post-data '' https://portainer.example.com/api/webhooks/WEBHOOK_TOKEN

Edge Agent (Remote Server Management)

Use Edge Agent to manage servers behind a firewall:

hljs bash
# In Portainer:
# Environments → Add Environment → Edge Agent
# Copy Edge ID and Edge Key

# Install Edge Agent on remote server:
docker run -d \
  --name portainer_edge_agent \
  --restart=always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /var/lib/docker/volumes:/var/lib/docker/volumes \
  -v /:/host \
  -v portainer_agent_data:/data \
  -e EDGE=1 \
  -e EDGE_ID=YOUR_EDGE_ID \
  -e EDGE_KEY=YOUR_EDGE_KEY \
  -e EDGE_INSECURE_POLL=1 \
  portainer/agent:latest

Updating Portainer

hljs bash
# Stop and remove current container
docker stop portainer
docker rm portainer

# Pull latest image
docker pull portainer/portainer-ce:latest

# Restart (data is preserved in volume)
docker run -d \
  --name portainer \
  --restart=always \
  -p 8000:8000 \
  -p 9443:9443 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer-ce:latest

By installing Portainer on REXE servers, you can manage all your Docker containers from a single web interface. It's especially convenient for servers running multiple services.