Portainer

Short recipe to run portainer + agent in a swarm.

Just create portainer.yml with your preferred editor:

version='3.7'

services:
  agent:
    image: portainer/agent
    environment:
      AGENT_CLUSTER_ADDR: tasks.agent
    volumes:
      - /var/run/docker.socket: /var/run/docker.sock
      - /var/lib/docker/volumes: /var/lib/docker/volumes
    deploy:
      mode: global

  portainer:
    image: portainer/portainer
    command: -H tcp://tasks.agent:9001 --tlsskipverify
    ports:
      - 9000:9000
    volumes:
      - portainer_data:/data
    deploy:
      mode: replicated
      replicas: 1

volumes:
  portainer_data:

Take care about the volume, if several nodes are present you should store the volume in any kind of shared access (i.e. NFS or GlusterFS) or restrict the portainer service to run always on the same node (i.e. placement constraint).

Enjoy! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.