Docker Community Forums

Share and learn in the Docker community.

How to create multiple hosts to test Docker Swarm locally?

swarm

#1

Hi!

Might be a bit off-topic, but here it goes…

I have been studying James Turnbull’s book The Docker Book, but I got stuck on chapter 7, where we start to look into Docker networking and Docker Swarm.

He starts a section with:

(…) we’d normally create three (or more) hosts to run in separate data centers, clouds or regions (…) We’re going to mimic this required distribution by creating three new hosts each with a Docker daemon( …) We will create three new Ubuntu 16.04 hosts (…) On each host we’ll install a Docker daemon.

He goes one with tip:

TIP Create the hosts using whatever means you run up new hosts and to install Docker you can use the installation instructions in Chapter 2.

I tried many Google searches but could not really find instruction on how to create these three new hosts (I’m on macOS Mojave). Can anyone point me to some instructions or give me some hints?

Thanks!!

Daniel


(Ove "Lime" Lindström) #2

Hi,
what you need is Docker Machine and VirtualBox. It is described here: https://docs.docker.com/machine/

It can be quite annoying to get it to work, but I have managed to run a couple of workers locally on my MBP (whit a lot of memory) for a class/demo. But quite frankly… it is easier to just register a AWS account and use free instances.

With VirtualBox and Docker Machine installed, open a terminal and make sure that it can see your host docker engine. Check it with docker info.

Now, run the command docker-machine create --driver virtualbox worker-1 and wait.
Then open a NEW Terminal window or tab and run the command eval $(docker-machine env worker-1). If you run docker info on that now, you will see that it is different.

On your first terminal (host), run the command docker swarm join-token worker and copy/past that into the worker-1 terminal.


(Ove "Lime" Lindström) #3

Hi again.
I found this great tutorial that guides you through the setup in a great way. Kudos to Melvin!


#4

That’s great! Will try it tonight.
Thanks a lot.