Getting started with Docker RC 1.12
Docker RC 1.12 is available and introduces some new features that will make things more easy ... but sometimes need some explanation :-)This set of commands will create a SWARM setup that is (according the documentation) fully secured using virtualbox
To create the vm's
docker-machine create -d virtualbox test112
docker-machine create -d virtualbox test112n1
docker-machine create -d virtualbox test112n2
Starting the vm's
docker-machine start test112
docker-machine start test112n1
docker-machine start test112n2
Setting of Swarm on the master node
eval $(docker-machine env test112)
docker swarm init --listen-addr $(docker-machine ip test112):2377
Setting of Swarm on worker node1
eval $(docker-machine env test112n1)
docker swarm init --listen-addr $(docker-machine ip test112):2377
Setting of Swarm on worker node2
eval $(docker-machine env test112n2)
docker swarm init --listen-addr $(docker-machine ip test112):2377
You can verify your setup
eval $(docker-machine env test112)
docker node ls
mymachine$ docker node ls
ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGER STATUS
5bvk0htdkyv9ksddzsy3wgnn6 test112n2 Accepted Ready Active
6dq3g4jtiak27pd56mpk06stx test112n1 Accepted Ready Active
e234397csi7wlt5dbj2ksu9qp * test112 Accepted Ready Active Leader
You can now create an overlay network
docker network create --driver=overlay my-net
And now your start the service ...
docker service create --replicas 1 --network my-net --name nginx nginx
... and now you can scale !
docker service scale nginx=5
If you plan to try-out the new load-balancing feature, use -p flag
docker service create --replicas 5 --network my-net --name -p 8888:80 nginx2 nginx
Note that in this case your services will be automatically distributed over all 3 nodes. On every node, port 8888, will be mapped to all the tasks(of the service to use the lingo :-)). (by default on Mac this is 192.168.99.100, 192.168.99.101, etc)
Because we use an overlay network, requests that are send to node1 on 192.168.99.100:8888 for example can also be distributed via the container overlay to all other nodes. You can check this by using the docker logs containerid
Another thing I noticed is that you cannot connect a container to a swarm scoped overlay directly.
So this will NOT work: docker run -it --net=my-net xxradar/hackon
Although, you can run docker run -it xxradar/hackon and link the container to the network like docker network connect my-net containerid
Have fun exploring !!