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.
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
# Create volume to store Portainer data
docker volume create portainer_data
Install Portainer CE
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
# 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:
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:
# 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
- Stacks → Add Stack
- Enter stack name
- Paste Docker Compose content or enter Git repository URL
- Add environment variables
- Click Deploy the stack
# 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
- Select Repository option when creating a stack
- Enter Git URL:
https://github.com/user/repo - Specify branch and compose file path
- Enable GitOps updates for automatic updates
Container Management
Container Operations
Operations available on containers from the Portainer interface:
# 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:
- Containers → Click on container name
- Console tab → Connect
- Select shell:
/bin/bashor/bin/sh
# Commands you can run inside the container:
ls -la /app
cat /etc/nginx/nginx.conf
nginx -t
env | grep DATABASE
Image Management
# 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
# 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
# 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
- Settings → Users → Add User
- Set username and password
- Assign role: Administrator or Standard User
Creating Teams
# From Portainer interface:
# Settings → Teams → Add Team
# Team name: developers
# Add members: user1, user2
Environment Access Control
# Environments → Select Environment → Access Control
# Grant access to specific users or teams
# Role: Manager (full access) or Operator (limited)
Automatic Updates with Webhooks
# 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:
# 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
# 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.
Related Articles
Coolify Setup: Application Deployment with Self-Hosted PaaS
Coolify installation, Docker and Git integration, application deployment, database management, SSL certificates, environment variables, and self-hosted PaaS alternative to Heroku/Netlify.
Nextcloud Setup: Self-Hosted Cloud Storage and Collaboration
Nextcloud installation with Docker, Apache/Nginx configuration, database setup, SSL certificate, file synchronization, app store, and performance optimization.
Uptime Kuma Setup: Self-Hosted Uptime Monitoring
Uptime Kuma installation with Docker, HTTP/TCP/DNS/ping monitoring, notification integrations (Telegram, Discord, email), status page creation, and alert configuration.