docker_practice/swarm_mode/create.md

79 lines
2.8 KiB
Go
Raw Normal View History

# Swarm
2017-11-25 09:43:04 +08:00
2018-03-10 08:34:46 +08:00
[](overview.md) `Swarm` **** **** `Swarm`
2017-11-25 09:43:04 +08:00
##
2017-11-25 09:43:04 +08:00
2018-03-10 08:34:46 +08:00
[`Docker Machine`](../machine) `Docker Machine` Docker 使 Docker
Docker
```bash
$ docker-machine create -d virtualbox manager
```
使 `docker swarm init` `Swarm`
2017-11-25 09:43:04 +08:00
```bash
2018-03-10 08:34:46 +08:00
$ docker-machine ssh manager
docker@manager:~$ docker swarm init --advertise-addr 192.168.99.100
2017-11-25 09:43:04 +08:00
Swarm initialized: current node (dxn1zf6l61qsb1josjja83ngz) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
192.168.99.100:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
```
Docker IP使 `--advertise-addr` IP
2018-03-10 08:34:46 +08:00
> `docker swarm init`
2017-11-25 09:43:04 +08:00
##
2017-11-25 09:43:04 +08:00
2018-03-10 08:34:46 +08:00
`Swarm` Docker
2017-11-25 09:43:04 +08:00
```bash
$ docker-machine create -d virtualbox worker1
$ docker-machine ssh worker1
docker@worker1:~$ docker swarm join \
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
192.168.99.100:2377
This node joined a swarm as a worker.
2017-11-25 09:43:04 +08:00
```
```bash
$ docker-machine create -d virtualbox worker2
$ docker-machine ssh worker2
docker@worker1:~$ docker swarm join \
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
192.168.99.100:2377
This node joined a swarm as a worker.
2017-11-25 09:43:04 +08:00
```
> `docker-machine create --help` `--swarm*` `Docker Swarm` `Swarm mode`
2017-11-26 09:54:16 +08:00
##
2017-11-25 09:43:04 +08:00
`Swarm`
使 `docker node ls`
```bash
$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
03g1y59jwfg7cf99w4lt0f662 worker2 Ready Active
9j68exjopxe7wfl6yuxml7a7j worker1 Ready Active
2018-03-10 08:34:46 +08:00
dxn1zf6l61qsb1josjja83ngz * manager Ready Active Leader
2017-11-25 09:43:04 +08:00
```