๐ Portainer Agent
![]()
Portainer Agent is a lightweight component that runs on Docker hosts to allow a central Portainer instance to manage them securely. It creates a secure tunnel between your main Portainer server and remote Docker environments without requiring direct Docker socket exposure over the network.
This allows you to manage multiple MOS Hub/Docker hosts from a single Portainer dashboard.
๐ท๏ธ Category: Productivity
๐ณ Image: portainer/agent:latest
๐ Links
| ย | ย |
|---|---|
| ๐ Website | portainer.io |
| ๐ Docs | docs.portainer.io |
| ๐ Support | GitHub Issues |
๐ Ports
| Port | Protocol | Description |
|---|---|---|
9001 | TCP | Portainer Agent communication port. The central Portainer instance connects to this port. |
๐พ Volumes
| Host Path | Container Path | Mode | Description |
|---|---|---|---|
/var/run/docker.sock | /var/run/docker.sock | RW | Docker socket for container management |
/var/lib/docker/volumes | /var/lib/docker/volumes | RW | Docker volumes directory |
/ | /host | RO | Host root filesystem (for volume browsing) |
โ๏ธ Environment Variables
| Variable | Default | Masked | Description |
|---|---|---|---|
AGENT_SECRET | `` | โ | Optional shared secret for authentication. Must match in Portainer when adding environment. |
PUID | 500 | โ | User ID for file permissions |
PGID | 500 | โ | Group ID for file permissions |
TZ | Europe/Vienna | โ | Timezone for the container |
๐ Quick Start
Architecture Overview
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Portainer โโโโโโโโโโถโ Portainer โ
โ (Central) โ :9001 โ Agent โ
โ Management โ โ (This Host) โ
โ Interface โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Local Docker โ
โ Environment โ
โโโโโโโโโโโโโโโโโโโ
Step 1: Install Portainer Agent via MOS Hub
- Open the MOS Hub and search for Portainer-Agent
- Click Install
- The agent will start on port
9001 - Make note of this hostโs IP address
Step 2: Get Host IP Address
Find the IP of this MOS Hub server:
ip addr show
Youโll need: http://HOST_IP:9001 for the next step.
Step 3: Add Environment in Central Portainer
On your main Portainer instance:
- Go to Environments โ Add Environment
- Select Docker Standalone
- Select Agent as the connection method
- Enter details:
- Name: MOS Hub Server (or any descriptive name)
- Environment URL:
http://HOST_IP:9001(replace with actual IP) - Agent Secret: (if you set
AGENT_SECRET, enter it here)
- Click Connect
Step 4: Verify Connection
- The environment should show as Up
- Click on the new environment to view its containers
- You can now manage this remote MOS Hub from your central Portainer!
๐ Security Considerations
Network Security
- Firewall: Only allow port 9001 access from your Portainer server IP
- Internal Network: Keep the agent on internal/VPN network if possible
- AGENT_SECRET: Always set a shared secret for production use
Privileged Access
โ ๏ธ Warning: The agent requires:
- Access to Docker socket (full container control)
- Access to host filesystem (for volume management)
- Privileged mode enabled
Only deploy the agent on hosts you trust and control completely.
๐ Use Cases
Centralized Management
Manage multiple MOS Hub servers from one dashboard:
- Home server
- VPS in cloud
- Raspberry Pi at another location
- Friendโs server (with permission!)
Remote Monitoring
Check container status, logs, and resource usage on remote hosts without SSH.
Remote Deployment
Deploy containers to remote hosts from your central Portainer interface.
๐ High Availability Setup
For production environments:
- Multiple Agents: Deploy agents on all Docker hosts
- Load Balancing: Use multiple Portainer replicas (BE feature)
- Backup: Backup Portainer data to restore connections
๐ Troubleshooting
Agent Not Connecting
- Check if agent is running:
docker ps | grep portainer-agent - Verify port is accessible:
curl http://localhost:9001Should return agent info.
-
Check firewall rules: Ensure port 9001 is open between Portainer and Agent.
- Check logs:
docker logs portainer-agent
Connection Timeout
- Verify IP address is correct
- Check network connectivity:
ping PORTAINER_IPfrom agent host - Ensure no NAT/firewall blocking port 9001
Authentication Failed
If using AGENT_SECRET:
- Ensure secret matches exactly in Portainer and Agent
- Restart agent after changing secret
โ ๏ธ Warning: The Portainer Agent has significant access to your Docker host. Only install it on hosts you control and trust. Never expose port 9001 to the public internet without firewall restrictions!
๐ก Tip: Use a VPN or private network for agent communication instead of exposing port 9001 publicly.
๐ก Tip: Set a strong
AGENT_SECRETto prevent unauthorized connections even if port 9001 is somehow accessed.
๐ก Tip: You can manage the Agent container itself through MOS Hub - but if you stop it, youโll lose remote management until you restart it locally!
๐ For more information: Visit the Portainer Agent Documentation for advanced configuration and Edge Agent setup.