informatica:linux:docker:red
This is an old revision of the document!
Creamos una subred swarm por ejemplo
# docker network create --subnet=172.19.0.0/16 swarm b61fd20f8ea5d6c53e70f938b4e1ce44333ba0fd993a333c5fb9fefc6cd2d1f3
# docker network ls NETWORK ID NAME DRIVER SCOPE ef49af878942 bridge bridge local 3016c3471d38 host host local e72a3fcddff2 none null local b61fd20f8ea5 swarm bridge local 15c7084e1eea weblogicnet bridge local
Miramos el detalle de la red:
# docker inspect swarm
[ { "Name": "swarm", "Id": "b61fd20f8ea5d6c53e70f938b4e1ce44333ba0fd993a333c5fb9fefc6cd2d1f3", "Created": "2017-02-13T18:10:44.25361846+01:00", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": {}, "Config": [ { "Subnet": "172.19.0.0/16" } ] }, "Internal": false, "Attachable": false, "Containers": {}, "Options": {}, "Labels": {} } ]
Ahora ejecutamos cada máquina con una ip:
# docker run --name swarm-nodo1 --privileged --net swarm --ip 172.19.0.101 --hostname swarm1 --add-host=swarm1:172.19.0.101 --add-host=swarm2:172.19.0.102 --add-host=swarm3:172.19.0.103 -ti swarm
# docker run --name swarm-nodo2 --privileged --net swarm --ip 172.19.0.102 --hostname swarm2 --add-host=swarm1:172.19.0.101 --add-host=swarm2:172.19.0.102 --add-host=swarm3:172.19.0.103 -ti swarm
# docker run --name swarm-nodo3 --privileged --net swarm --ip 172.19.0.103 --hostname swarm3 --add-host=swarm1:172.19.0.101 --add-host=swarm2:172.19.0.102 --add-host=swarm3:172.19.0.103 -ti swarm
Creamos swarm en el primer nodo
# docker swarm init --advertise-addr 172.19.0.101
Swarm initialized: current node (obtavwk9ypnpq20ubd54gt7me) is now a manager. To add a worker to this swarm, run the following command: docker swarm join \ --token SWMTKN-1-5wvvfc5qpmk4avbqzv0iw1st0qxtwb15ut0phwyjgmv2iw65t7-akxww3rmtsimaihqokcgmwu7a \ 172.19.0.101:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
Si hacemos docker info, vemos swarm:
# docker info
......... Swarm: active NodeID: obtavwk9ypnpq20ubd54gt7me Is Manager: true ClusterID: tbzs05pa17b5vkseyzzmc2sew Managers: 1 Nodes: 1 .........
Podemos ver los nodos activos:
# docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS obtavwk9ypnpq20ubd54gt7me * swarm1 Ready Active Leader
El * indica que actualmente estamos conectados a ese nodo
Desde el manager, sacamos el token para unir a los otros:
# docker swarm join-token worker
To add a worker to this swarm, run the following command: docker swarm join \ --token SWMTKN-1-5wvvfc5qpmk4avbqzv0iw1st0qxtwb15ut0phwyjgmv2iw65t7-akxww3rmtsimaihqokcgmwu7a \ 172.19.0.101:2377
Lanzamos ese comando en los otros dos nodos y vemos que se han unido:
# docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS bz11p92f0ietyc2rvv8zs63dt swarm3 Ready Active mzjrvtr4519idowp10y1lowfy swarm2 Ready Active obtavwk9ypnpq20ubd54gt7me * swarm1 Ready Active Leader
informatica/linux/docker/red.1487016444.txt.gz · Last modified: 2017/02/13 20:07 by jose