docker swarm集群
Docker Swarm 是 Docker 的集群管理工具。
Docker Swarm 将 Docker 主机池转变为单个虚拟 Docker 主机;
任何已经与 Docker 守护程序通信的工具都可以使用 Swarm 轻松地扩展到多个主机。
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default - virtualbox Running tcp://192.168.99.100:2376 v19.03.5 swarm-manager - virtualbox Running tcp://192.168.99.104:2376 v19.03.5
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine create -d virtualbox swarm-manager Running pre-create checks... Creating machine... (swarm-manager) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/swarm-manager/boot2docker.iso... (swarm-manager) Creating VirtualBox VM... (swarm-manager) Creating SSH key... (swarm-manager) Starting the VM... (swarm-manager) Check network to re-create if needed... (swarm-manager) Waiting for an IP... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with boot2docker... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env swarm-manager
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine create --engine-registry-mirror=https://92u4e4x7.mirror.aliyuncs.com -d virtualbox swarm-work1 Running pre-create checks... (swarm-work1) Unable to get the latest Boot2Docker ISO release version: Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 13.250.168.23:443: connect: connection refused Creating machine... (swarm-work1) Unable to get the latest Boot2Docker ISO release version: Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 13.250.168.23:443: connect: connection refused (swarm-work1) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/swarm-work1/boot2docker.iso... (swarm-work1) Creating VirtualBox VM... (swarm-work1) Creating SSH key... (swarm-work1) Starting the VM... (swarm-work1) Check network to re-create if needed... (swarm-work1) Waiting for an IP... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with boot2docker... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env swarm-work1
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine ssh swarm-manager ( '>') /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. (/-_--_-\) www.tinycorelinux.net
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine create --engine-registry-mirror=https://92u4e4x7.mirror.aliyuncs.com -d virtualbox swarm-work2 Running pre-create checks... (swarm-work2) Unable to get the latest Boot2Docker ISO release version: Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 13.250.168.23:443: connect: connection refused Creating machine... (swarm-work2) Unable to get the latest Boot2Docker ISO release version: Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 13.250.168.23:443: connect: connection refused (swarm-work2) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/swarm-work2/boot2docker.iso... (swarm-work2) Creating VirtualBox VM... (swarm-work2) Creating SSH key... (swarm-work2) Starting the VM... (swarm-work2) Check network to re-create if needed... (swarm-work2) Waiting for an IP... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with boot2docker... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env swarm-work2
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine create --engine-registry-mirror=https://92u4e4x7.mirror.aliyuncs.com -d virtualbox swarm-work3 Running pre-create checks... (swarm-work3) Unable to get the latest Boot2Docker ISO release version: Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 13.250.168.23:443: connect: connection refused Creating machine... (swarm-work3) Unable to get the latest Boot2Docker ISO release version: Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 13.250.168.23:443: connect: connection refused (swarm-work3) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/swarm-work3/boot2docker.iso... (swarm-work3) Creating VirtualBox VM... (swarm-work3) Creating SSH key... (swarm-work3) Starting the VM... (swarm-work3) Check network to re-create if needed... (swarm-work3) Waiting for an IP... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with boot2docker... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env swarm-work3
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS swarm-manager - virtualbox Running tcp://192.168.99.104:2376 v19.03.5 swarm-work1 - virtualbox Running tcp://192.168.99.105:2376 v19.03.5 swarm-work2 - virtualbox Running tcp://192.168.99.106:2376 v19.03.5 swarm-work3 - virtualbox Running tcp://192.168.99.107:2376 v19.03.5
docker@swarm-manager:~$ docker swarm init --advertise-addr 192.168.99.104 Swarm initialized: current node (c6850rrb4jz1vqc8t8t9p1gyy) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-49x5q0la5yupv6jedho9gxv0t34d9rtd7l8qd5p725t1nezl1q-60ste25379mpxqk4kaf59ly8r 192.168.99.104:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions. docker@swarm-manager:~$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION c6850rrb4jz1vqc8t8t9p1gyy * swarm-manager Ready Active Leader 19.03.5 docker@swarm-manager:~$ exit logout
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS swarm-manager - virtualbox Running tcp://192.168.99.104:2376 v19.03.5 swarm-work1 - virtualbox Running tcp://192.168.99.105:2376 v19.03.5 swarm-work2 - virtualbox Running tcp://192.168.99.106:2376 v19.03.5 swarm-work3 - virtualbox Running tcp://192.168.99.107:2376 v19.03.5
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine ssh swarm-work1
( ‘>’)
/) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY.
(/-–-) www.tinycorelinux.net
docker@swarm-work1:~$ docker swarm join --token SWMTKN-1-49x5q0la5yupv6jedho9gxv0t34d9rtd7l8qd5p725t1nezl1q-60ste25379mpxqk4kaf59ly8r 192.168.99.104:2377
This node joined a swarm as a worker.
docker@swarm-work1:~$ exit
logout
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine ssh swarm-work2
( ‘>’)
/) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY.
(/-–-) www.tinycorelinux.net
docker@swarm-work2:~$ docker swarm join --token SWMTKN-1-49x5q0la5yupv6jedho9gxv0t34d9rtd7l8qd5p725t1nezl1q-60ste25379mpxqk4kaf59ly8r 192.168.99.104:2377
This node joined a swarm as a worker.
docker@swarm-work2:~$ exit
logout
root@wm-MS-7C37:/home/wm/Downloads/Programs/docker# docker-machine ssh swarm-manager ( '>') /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. (/-_--_-\) www.tinycorelinux.net
docker@swarm-manager:~$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION c6850rrb4jz1vqc8t8t9p1gyy * swarm-manager Ready Active Leader 19.03.5 ojgbqy2ukzdzgmthr4u24nnmi swarm-work1 Ready Active 19.03.5 ednnsnd7iq9b968trknmwczfv swarm-work2 Ready Active 19.03.5