Today, a very quick blog post to continue the series of my docker swarm services recipes. If you haven't, I suggest reading some of my my home lab posts to give you an idea if you don't already have an understanding of a docker swarm architecture.
As indicated on their website: Portainer1:
Build and manage your Docker environments with ease today.
In a simple configuration with docker running standalone (meaning not with kubernetes or swarm mode), you can just run the portainer/portainer container on your server, but in a swarm mode, you need to deploy agents on each node that will communicate with portainer server.
Create directory structure first, if you follow my filesystem structure2, just do:
Then, create the
version: '3' services: agent: image: portainer/agent volumes: - /var/run/docker.sock:/var/run/docker.sock - /var/lib/docker/volumes:/var/lib/docker/volumes networks: - agent_network deploy: mode: global placement: constraints: [node.platform.os == linux] portainer: image: portainer/portainer command: -H tcp://tasks.agent:9001 --tlsskipverify ports: - 9000:9000 - 8000:8000 #changeme networks: - agent_network deploy: mode: replicated replicas: 1 placement: constraints: - node.role == manager volumes: - /mnt/cluster-data/containers-data/portainer/:/data #changeme if you don't use this file structure networks: agent_network: driver: overlay
Important piece are:
- Portainer agent is deployed globally (
mode: global), this means that each node will have 1 instance of this container.
- Portainer server is deployed only on manager nodes.
- The constraints is just there to "look good", because I don't have anything else than linux platform anyway :p.
Deploy the stack:
docker stack deploy portainer -c /mnt/cluster-data/services-config/portainer/docker-compose.yml
You can then go to
http://<ClusterIPAddress:8000, to create your user and configure portainer (select environment local and then create your user)
And stop it:
docker stack rm portainer
That's it for now, I did say it would be a very quick one :).
You can follow all posts about my Home Lab setup on the dedicated page.
All Docker Swarm Services configuration:
In the Home Lab setup series:
- 2020-05-02 My Home Lab 2020, part 7: Keeping containers' log in rotation with logrotate
- 2020-04-30 My Home Lab 2020, part 6(v1): Temporary backup system
- 2020-04-28 My Home Lab 2020, part 5: External application status with Statping
- 2020-03-30 My Home Lab 2020, part 4: Running Services over https with Traefik
- 2020-03-27 My Home Lab 2020, part 3: Docker Swarm setup
- 2020-03-24 My Home Lab 2020, part 2: GlusterFS Setup
- 2020-03-21 My Home Lab 2020, part 1: Context and Architecture choices