Portainer
INFO
Portainer's hybrid & multi-cloud container management software supports Kubernetes, Docker, Swarm in any data centre, cloud, network edge or IIoT device.
Install Docker Compose
First, you'll need to install Docker Compose on your system. Docker Compose is a tool that allows you to define and run multi‑container Docker applications. You can follow the official instructions here.
Create Docker Compose file
Next, create a Docker Compose file named docker-compose.yml in a directory of your choice. Here's an example file:
version: '3'
services:
portainer:
image: portainer/portainer-ce:latest
restart: always
ports:
- "8000:8000"
- "9000:9000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
deploy:
placement:
constraints:
- node.role == manager
edge-agent:
image: portainer/agent:latest-edge
command: edge
environment:
AGENT_CLUSTER_ADDR: tasks.portainer_portainer
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- portainer_agent_network
deploy:
mode: global
placement:
constraints:
- node.platform.os == linux
networks:
portainer_agent_network:
driver: overlay
attachable: true
volumes:
portainer_data:This file defines two services: portainer and edge-agent.
The portainer service runs the latest version of the Portainer Community Edition Docker image, maps the container's TCP ports 8000 and 9000 to the host's TCP ports 8000 and 9000, and mounts two volumes from the host to the container: /var/run/docker.sock and portainer_data.
The edge-agent service runs the latest Edge version of the Portainer Agent Docker image, sets the AGENT_CLUSTER_ADDR environment variable to the address of the portainer service, mounts two volumes from the host to the container: /var/run/docker.sock and /var/lib/docker/volumes, and connects to the portainer_agent_network network. The service is set to deploy in global mode (i.e., one instance per node) and is constrained to run only on Linux nodes.
Start Portainer and Edge Agent containers
After creating the Docker Compose file, you can start the Portainer and Edge Agent containers using the following command:
docker-compose up -dThis command starts the containers in detached mode (in the background).
Access Portainer web interface
To access the Portainer web interface, open a web browser and navigate to http://<hostname>:9000, where <hostname> is the hostname or IP address of the node running the portainer service.
Add Edge Agent to Portainer
To add the Edge Agent to Portainer, follow these steps:
- Log in to the Portainer web interface.
- Click on the "Endpoints" tab.
- Click on the "Add endpoint" button.
- Select "Docker environment" as the endpoint type.
- Enter a name for the endpoint (e.g., "Edge Agent").
- Enter the endpoint URL as
tcp://edge-agent:9001. - Check the "Deploy an edge agent" box.
- Click on the "Create endpoint" button.
