Docker Community Forums

Share and learn in the Docker community.

Docker Swarm getting started


(Hannu Visti) #1

Hi all, my first post here.

I have been trying to get Swarm up and running, but with no success. The internet is full of tutorials, but they all seem to rely on some kind of a virtualbox hack using Docker Machine.

I have Openstack instances that are orchestrated from somewhere else, and I would like to run dockerised applications in these, and use Swarm to discover and coordinate this. If I have understood anything from the docs, I do not need Docker Machine or Virtualbox.

Is there a good tutorial that would not rely on these? I was (probably) able to run swarm creation to get a token, and run swarm joins and swarm manage, but this never created a cluster of any kind between my cloud instances. I am obviously missing something here, and a good tutorial would be handy…

Hannu


(Cboberg) #2

I fully agree. Im also trying to figure out how to run Swarm on my already provisioned VMs.
Did you find any good tutorials that did not rely on Docker-machine?


(Hannu Visti) #3

Hi,

I did not manage to find any tutorials, but I managed to get it work, and it actually works quite nicely. I don’t remember anymore what was the key thing to get it up and running, but in the end it was rather simple.

If I remember it correctly, the essential thing was to start using Consul and replace the swarm token with consul token. If you create a cluster purely on Swarm, it is a static construction (or at least was with the version I am using). You had to start all worker nodes with swarm join first and then swarm manage, but addition of nodes was not possible.

If you use consul, then you get a dynamic Swarm cloud and the ability to add and remove nodes without problems. And I do not run Swarm or Consul inside containers but on the cloud instance itself. I use Atlas tokens (free service, google it) to bootstrap my consul cluster.

The other issue I can remember, that is purely cloud related, was reseeding of docker and consul. I initially created a cloud image with all relevant appliations, spawned a couple of instances and hoped to get a nicely working Swarm cloud. Except that I didn’t. I got exactly one working node out of several.

The problem, as it appears, was that my cloud instance I used to create the image had already started docker and consul. When they start the first time, they create random id:s and other stuff. This was then replicated to all instances I spawned using this image, and a cluster refused to form as there were overlapping identifiers.

I had to do something like this in a script when starting a new cloud instance the first time (not sure if the sleeps are necessary, did not bother to test as it worked as it is):

sudo service consul stop
sudo rm -f /var/consul/* > /dev/null 2>&1
sudo service consul start
sleep 2

sudo service docker stop
sudo rm -f /etc/docker/key.json > /dev/null 2>&1
sudo service docker start
sleep 3

Hope this helps.

Hannu