Skip to content

Instantly share code, notes, and snippets.

@scyto
Last active December 11, 2023 22:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save scyto/0a9b71f35d375d4dba6c1c5aba0045f3 to your computer and use it in GitHub Desktop.
bootstrap docker swarm

i like using docker swarm for home labs

assumes you installed docker like this

Initialize Swarm on first docker node (management node)

sudo docker-swarm init

it will produced output something like this

docker swarm join --token <some-very-long-token> 192.168.1.41:2377

make sure you copy and keep this command as you will run it on all your other nodes (the IP address should match the IP of this management node, if it doesn't you need to troubleshoot networking).

Initialize worker nodes

On each worker node run the command from the last step

sudo docker swarm join --token <some-very-long-token> 192.168.1.41:2377

the IP is the IP of the management node and doesn't need to be changed as you run this on each node.

thats it you should now have a fully functioning swarm

@scyto
Copy link
Author

scyto commented Apr 20, 2023

since creating this gist i figured out how to run portainer as a swarm service - as such i made every node a manager node too.

@briodan
Copy link

briodan commented Nov 9, 2023

quick note there is a typo in the initialize docker command it should me

sudo docker swarm init

@OlivierMary
Copy link

quick note there is a typo in the initialize docker command it should me

sudo docker swarm init

+1

maybe consider set all node as manager: https://docs.docker.com/engine/swarm/admin_guide/#add-manager-nodes-for-fault-tolerance

@scyto
Copy link
Author

scyto commented Dec 11, 2023

lol, yeah did that a long time ago, never bothered documenting it
it is required to have portainer become a swarm app (which one should never do of course ;-) )

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