How to Manage Docker Machine With Swarm on Virtualbox

Docker introduces swarm mode in version 1.12. This mode allows users to deploy containers on multiple hosts or nodes, using the overlay network. Swarm mode is part of the Docker command line interface that makes it easy for users to manage container components if they are familiar with the commands in Docker This docker swarm can help us to group existing docker-dockers and group them into one group. So that we can arrange everything in one place, namely swarm using the CLI Docker. The picture above can be simulated if we have 3 dockers, and all of us are connected with swarm. Docker swarm is the same as loading the balance of a request that goes into swarm, then forwarded to the backend of the docker swarm. Poker-Machine Docker-machine is a tool that we install on docker -engine. Docker-machines run on virtual hosts. Its function is to manage hosts on our local computer. With docker-machines we can make hosts on a local computer, or windows box, which can be used for company network, data-center, AWS, and Digital Ocean.


  • Installed Docker Machine
  • Virtualbox or VMWare
  1. Crate Docker-Machine A total of 3 pieces consist of Manager-Worker1-Worker2

“docker-machine create — driver virtualbox manager”

“docker-machine create — driver virtualbox worker1”

“docker-machine create — driver virtualbox worker2”

2. To make sure you can check with “docker-machine ls”

There looks ip on worker1 is, while ip worker2 is and

3. Then check ip on the host laptop, the address is

Here ip will I make as a leader which means its duty to arrange its employees, while worker1 and worker2 as a worker will work with the leader.

4. How to connect the workers with the leader by giving the token, to its employees?

“docker swarm init –advertise-addr”

if you have checked how many tokens from the leader

“docker swarm join-token -q worker”

5. Then we enter the token in the workers, namely worker1 and worker2. Enter worker1 and worker2 by ssh

“docker-machine ssh worker1”


“docker swarm join — token “tokennya yand ada dileader”

do the same way with worker2

6. if so, check that all are connected to each other

“docker node ls”

if the result as above means successful.

To ascertain whether Node / Worker that has been made running can be opened Virtualbox with Running information and there are three “Manager-Worker1-Worker2”

Now we try to make the images into the nodes that have been made before.

here I will use images “rahmatmustaqim / staticweb”

“docker service create — name docker-swarm1 -p 81:80 — replicas 2 rahmatmustaqim/staticwe”

Note : — name “swarm1”: how much do you want to fill in what name (free)
-p 81:80: move to port 81 from port 80
- rahmatmustaqim / staticwe: is the image name used.

if it is already, now try running it through the browser, call <ip leader>: <port

If it is View Using Ip Worker1

If it’s ViewUsing Ip Worker2

check the service on the docker.

Now we will set the scaling .. scale is arguably like load sharing / load balancing

7. Now we will set the scaling .. scale is arguably like load sharing / load balancing

“sudo docker service scale swarm1=6”

If it works like the picture above, now we check whether everything is working properly

“docker service ps swarm1”

Can be seen as shown above, that the machine has been running as much as 6. So if the engine turns off one will immediately be transferred to the next machine, because there is an automatic backup immediately

“docker service update — limit-cpu 1 — limit-memory 256mb swarm1”

And then chek

“docker service inspect — pretty swarm1”

Memory has been set to 256m

OK until here, learning about Docker Swarm.

UI/UX, Cloud Computing also Renewable Energy Enthusiast and Still learn new things everyday