Skip to content

Instantly share code, notes, and snippets.

@scyto
Last active April 1, 2025 07:29
Show Gist options
  • Save scyto/a57d63a3b905b24e9eb25618848c8e80 to your computer and use it in GitHub Desktop.
Save scyto/a57d63a3b905b24e9eb25618848c8e80 to your computer and use it in GitHub Desktop.
Installing Portainer on a swarm

This is how to install portainer on the swarm you created using this gist note this should work on non-swarm installs too!

Setup Portainer

Download the portain stack yaml that will do this for you

curl -L https://downloads.portainer.io/ce2-17/portainer-agent-stack.yml -o portainer-agent-stack.yml

now run it

sudo docker stack deploy -c portainer-agent-stack.yml portainer

this will create a single portainer container that runs on the management node and deploy the agent to all worker nodes, once complete you can now access portainer at http://docker-host-ip:9000 and define your admin users etc

You now have a fully function docker swarm with portainer and can deploy containers, stacks or templates.

How to use portainer is beyond the scope of this gist

This is the portainer install doc at time of writing for reference but the instructions above will work just fine

@Jens-Wymeersch
Copy link

I looked at the docs, it doesn't specify if you need to run it in the master node or in all nodes.

@pderuiter
Copy link

pderuiter commented Apr 1, 2025

IF you mounting the filesystem at boot if so you need to make sure fstab doesn't try and mount them utill the network AND the ceph/glsuter services are full up and operational (not just started)

this will require you mess with service dependencies...

consider running a scripted mount command instead of relying on fstab

this was one reason I used the volume driver, can't recall if i modified docker service to start only once gluster was fully up

If thats not the issue maybe you have an inherent networking issue, do all your nodes have names registered in DNS and it might be worth putting all nodes in /etc/hosts - sometimes found gluster would rever to wanting to use nodename for no reason i could fathom

A bit late comment, but by adding the "_netdev" to your mount options in the /etc/fstab file will solve the problem of mounting before the network is online.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment