I've been following the docker swarm instructions and come to the 'Launch the Swarm manager' section where I'm told to issue this command:
docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://2144765674e460fbd53cf4bfcfb59207 swarm-master
Can someone explain the difference between this can the create
command I issued earlier:
docker-machine create -d virtualbox local
In both instances you seem to be creating something on virtualbox - is it that in one you are making a slave and the other a master?
The first command creates a a new virtualbox VM. You then need to run the docker run swarm create
command to generate a discovery token with Docker's centrally-hosted Swarm Discovery service. The other nodes (including the manager) are all linked together with this unique token.
The second command is actually creating the Swarm manager machine. The first machine (local
) doesn't actually do anything (except run the container to generate the token) iirc, so after generating it and saving it you can probably kill that machine. There's also no reason you couldn't just generate that (using docker run swarm create
) on a local Docker install (if you have one) and skip creating the local
VM altogether.
Also probably worth mentioning this is the 'old' way of creating a Docker Swarm cluster. If you're coming to this 'fresh', the current 'best practise' is to use Docker Swarm Mode (Engine version 1.12 and above). Natively integrated with the engine and with way less complexity / external dependencies.
More info on Docker Swarm Mode here and an answer on SO (by me) explaining the differences here.