Ubuntu System types
Test Docker Management Operations user
192.168.1.73 Swarm-node
192.168.1.80 Swarm-master
1. Swarm-master Create a cluster
1.1 Switching between active hosts
[Email protected]:~$ docker-machinelsNAME ACTIVE DRIVER State URL SWARM DOCKER ERRORS the* Generic Running TCP://192.168.1.73:2376 V17.06.0-ce the-Generic Running TCP://192.168.1.80:2376 V17.06.0-ce[Email protected]:~$ docker-machine Active theError:too Many arguments Given[email protected]:~$ docker-Machine Active the[email protected]:~$ Eval $ (docker-machineEnv the) [email protected]:~$ docker-Machine Active the
1.2 Creating a Swarn image
[Email protected]:~$ Docker run swarm createunable to find image " swarm:latest " locallylatest:pulling from library /swarm248cc99c8148:pull complete 0aeceddbda61:pull complete c90a34ed5817:pull Complete digest:sha256:02040b8e8292aacb6e30be8babd613f1c253a3ec665d2fbc178d1745810fdd29status:downloaded Newer Image for Swarm:latesttoken based Discovery is now deprecated and might be removed in the future. It'll be replaced by a default discovery backed by Docker Swarm mode.other mechanisms such as consul and Etcd would Conti Nue to work as EXPECTED.3E2A3FA482C1994AD5EE684F120E27C4
#最后一行为CLUSTER_ID一定保留下好, the additional nodes below will be used
1.3 Increasing the main control node Swarm-master
[Email protected]:~$ docker-machine Create--driver generic--swarm--swarm-master--swarm-discovery token://3e2a3fa482c1994ad5ee684f120e27c4 Swarm-masterError setting machine configuration from the flags Provided:generic driver requires the--generic-ip-address Option[email protected]:~$ docker-machine Create--driver generic--generic-ip-address=192.168.1.80--generic-SSH-key ~/.SSH/id_rsa--generic-SSH-user=test--swarm--swarm-master--swarm-discovery token://3e2a3fa482c1994ad5ee684f120e27c4 Swarm-masterRunning pre-Create Checks ... Creating machine ... (Swarm-Master) Importing SSH Key ... Waiting forMachine to is running, this could take a few minutes ... Detecting operating system of created instance ... Waiting forSSH to be available ... Detecting the Provisioner ... Provisioning with Ubuntu (SYSTEMD) ... Installing Docker ... Copying certs to the Local machine directory ... Copying certs to the remote ... Setting Docker configuration on the remote daemon ... Configuring Swarm ... Checking connection to Docker ... Docker is up and running!your Docker Client to the Docker Engine running on this virtual machine, Run:docker-machineEnvswarm-Master[email protected]:~$ Docker-machinelsNAME ACTIVE DRIVER State URL SWARM DOCKER ERRORS the-Generic Running TCP://192.168.1.73:2376 V17.06.0-ce the* Generic Running TCP://192.168.1.80:2376 V17.06.0-ceSwarm-master * Generic Running TCP://192.168.1.80:2376 swarm-master (master) v17.06.0-ce
1.4 Adding SWARM nodes
#普通节点没有--swarm-master Options
[Email protected]:~$ docker-machine Create--driver generic--generic-ip-address=192.168.1.73--generic-SSH-key ~/.SSH/id_rsa--generic-SSH-user=test--swarm--swarm-discovery Token://3e2a3fa482c1994ad5ee684f120e27c4 swarm-node1Running pre-Create Checks ... Creating machine ... (Swarm-Node1) Importing SSH Key ... Waiting forMachine to is running, this could take a few minutes ... Detecting operating system of created instance ... Waiting forSSH to be available ... Detecting the Provisioner ... Provisioning with Ubuntu (SYSTEMD) ... Installing Docker ... Copying certs to the Local machine directory ... Copying certs to the remote ... Setting Docker configuration on the remote daemon ... Configuring Swarm ... Checking connection to Docker ... Docker is up and running!your Docker Client to the Docker Engine running on this virtual machine, Run:docker-machineEnvswarm-Node1[email protected]:~$ Docker-machinelsNAME ACTIVE DRIVER State URL SWARM DOCKER Errorsswar M-master * Generic Running TCP://192.168.1.80:2376 swarm-master (master) v17.06.0-ceSwarm-node1-generic Running TCP://192.168.1.73:2376 swarm-master v17.06.0-ce
1.5 View swarm status
ls ID HOSTNAME STATUS availability MANAGER status0jmswkqce9cqjvri9awdm37ty swarm-node1 Ready Active * swarm-master ready Active Leader
2 Management Swarm
2.1 Exiting the cluster
[Email protected]:~$ docker swarm Leave--Forcenode left the swarm.
#使用docker-machine switch environment to exit the cluster in Swarm-node1,swarn-master, the following only involves switching the environment does not provide code see 1.1
2.2 Swarm-master Building a cluster
[Email protected]:~$ docker swarm initswarm initialized:current node (69NKAQU3IVFMTY5ISZ0UG0OIW) is now a manage R.to Add a worker to this swarm, run the following command: join --token swmtkn-1192.168. 1.80:2377'Docker swarm Join-token manager' and follow the Instructions.
#同样token很重要, do not lose, Docker code hints are clear, join the cluster command is placed there
2.3 Swarm-node1 Join the cluster
[email protected]:~$ docker swarm join --token swmtkn-1 -1qj2mfe14jw2tzhg1fxpqiyhxpnm4bqhrhae0dtpp6ip9og4s3-btyj7t5304eyeuhrl4dw1vx1l 192.168 . 1.80 : 2377 This node joined a swarm as a worker. [email protected]: ~$ eval $ (docker-machine env swarm-master) [email protected]: ~$ docker node ls id HOSTNAME STATUS availability MANAGER S Tatus0jmswkqce9cqjvri9awdm37ty swarm -node1 ready Active 69NKAQU3IVFMTY5ISZ0UG0OIW * Swarm-master ready Active Leader
Docker Three Musketeers (2) Docker-machine Installation & Management swarm