What #
Set up Portainer for local and remote docker management
Why #
- Simplifies the deployment and management of containerized services (Docker, Kubernetes…)
- Portainer supports multi-cluster environments.
How #
Setup with docker compose #
docker-compose-portainer.yaml
volumes:
portainer_data:
driver: local
services:
portainer:
image: portainer/portainer-ce:2.21.5
container_name: portainer
command: -H unix:///var/run/docker.sock
ports:
- "8000:8000"
- "9443:9443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
restart: always
run with:
docker compose -f docker-compose-portainer.yaml up -d
access Portainer at https://localhost:9443
Setup Portainer docker agent #
On remote server set the agent with docker-compose
docker-compose-portainer-agent.yaml
services:
portainer-agent:
image: portainer/agent:2.21.5
container_name: portainer-agent
ports:
- "9001:9001"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
restart: always
run with:
docker compose -f docker-compose-portainer-agent.yaml up -d
Connect agent #
Go to Portainer menu -> Environments. Click ‘Add environment’
Select Docker Standalone. Click ‘Start wizard’
Enter environment name and environment address (remote host and agent port)