Sie sind auf Seite 1von 7

T+4��ȫ��������ʾ

� ���‫� ش���ؽ‬
PO&ASN�޸���

PS C:\WINDOWS\system32> docker-machine create -d hyperv --hyperv-virtual-switch


"myswitch" myvm1
Running pre-create checks...
Creating machine...
(myvm1) Copying C:\MACHINE\cache\boot2docker.iso to
C:\MACHINE\machines\myvm1\boot2docker.iso...
(myvm1) Creating SSH key...
(myvm1) Creating VM...
(myvm1) Using switch "myswitch"
(myvm1) Creating VHD
(myvm1) Starting VM...
(myvm1) Waiting for host to start...
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: C:\Program Files\Docker\Docker\Resources\
bin\docker-machine.exe env myvm1
PS C:\WINDOWS\system32> docker-machine env myvm1
$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://192.168.43.89:2376"
$Env:DOCKER_CERT_PATH = "C:\MACHINE\machines\myvm1"
$Env:DOCKER_MACHINE_NAME = "myvm1"
$Env:COMPOSE_CONVERT_WINDOWS_PATHS = "true"
# Run this command to configure your shell:
# & "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env myvm1 |
Invoke-Expression
PS C:\WINDOWS\system32> docker-machine create -d hyperv --hyperv-virtual-switch
"myswitch" myvm2
Running pre-create checks...
Creating machine...
(myvm2) Copying C:\MACHINE\cache\boot2docker.iso to
C:\MACHINE\machines\myvm2\boot2docker.iso...
(myvm2) Creating SSH key...
(myvm2) Creating VM...
(myvm2) Using switch "myswitch"
(myvm2) Creating VHD
(myvm2) Starting VM...
(myvm2) Waiting for host to start...
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: C:\Program Files\Docker\Docker\Resources\
bin\docker-machine.exe env myvm2
PS C:\WINDOWS\system32> docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER
ERRORS
myvm1 - hyperv Running tcp://192.168.43.89:2376 v17.09.0-ce
myvm2 - hyperv Running tcp://192.168.43.102:2376 v17.09.0-ce
PS C:\WINDOWS\system32> docker-machine ssh myvm1
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 17.09.0-ce, build HEAD : 06d5c35 - Wed Sep 27 23:22:43 UTC 2017
Docker version 17.09.0-ce, build afdb6d4
docker@myvm1:~$ docker swarm init --advertise-addr 192.168.43.89
Swarm initialized: current node (s5dbk3t9mx6yieb4zuqy8k6ja) is now a manager.

To add a worker to this swarm, run the following command:

docker swarm join --token SWMTKN-1-


0hb2xbps6tfhzd268v9o7q9bu9vxvvtv8rdls2j0vvym76t6nf-eelgdf3u7oivxym7pl2hf9h6h
192.168.43.89:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow
the instructions.

docker@myvm1:~$ exit
PS C:\WINDOWS\system32> docker-machine ssh myvm2
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 17.09.0-ce, build HEAD : 06d5c35 - Wed Sep 27 23:22:43 UTC 2017
Docker version 17.09.0-ce, build afdb6d4
docker@myvm2:~$ docker swarm join --token SWMTKN-1-0hb2xbps6tfhzd268v9o7q9bu9vxv
vtv8rdls2j0vvym76t6nf-eelgdf3u7oivxym7pl2hf9h6h 192.168.43.89:2377
This node joined a swarm as a worker.
docker@myvm2:~$ exit
PS C:\WINDOWS\system32> docker node ls
ID HOSTNAME STATUS AVAILABILITY
MANAGER STATUS
iwlvag90ftza9vmibuo80cx13 * moby Ready Active
Leader
PS C:\WINDOWS\system32> docker-machine ssh myvm1 "docker node ls"
ID HOSTNAME STATUS AVAILABILITY
MANAGER STATUS
s5dbk3t9mx6yieb4zuqy8k6ja * myvm1 Ready Active
Leader
md9w91fg1apjco5bxz0gijxvu myvm2 Ready Active
PS C:\WINDOWS\system32> docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER
ERRORS
myvm1 - hyperv Running tcp://192.168.43.89:2376 v17.09.0-ce
myvm2 - hyperv Running tcp://192.168.43.102:2376 v17.09.0-ce
PS C:\WINDOWS\system32> cd C:\Users\25386\Desktop\guide
PS C:\Users\25386\Desktop\guide> docker stack deploy -c docker-compose.yml
getstartedlab
Creating network getstartedlab_webnet
Creating service getstartedlab_web
PS C:\Users\25386\Desktop\guide> docker stack ps getstartedlab
ID NAME IMAGE NODE
DESIRED STATE CURRENT STATE ERROR
PORTS
sktwyru4s91p getstartedlab_web.1 xianchangjie/yj:v1 moby
Running Running 4 seconds ago

6unpzgpk72g6 getstartedlab_web.2 xianchangjie/yj:v1 moby


Running Running 4 seconds ago

rj0d3grok3vd getstartedlab_web.3 xianchangjie/yj:v1 moby


Running Running 4 seconds ago

qsts7ibc0b9u getstartedlab_web.4 xianchangjie/yj:v1 moby


Running Running 4 seconds ago

ffcznos9ur17 getstartedlab_web.5 xianchangjie/yj:v1 moby


Running Running 4 seconds ago

ruehfyelewid getstartedlab_web.6 xianchangjie/yj:v1 moby


Running Running 3 seconds ago

PS C:\Users\25386\Desktop\guide> docker stack rm getstartedlab


Removing service getstartedlab_web
Removing network getstartedlab_webnet
PS C:\Users\25386\Desktop\guide> docker stack ps getstartedlab
nothing found in stack: getstartedlab
PS C:\Users\25386\Desktop\guide> docker-machine ssh myvm1
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 17.09.0-ce, build HEAD : 06d5c35 - Wed Sep 27 23:22:43 UTC 2017
Docker version 17.09.0-ce, build afdb6d4
docker@myvm1:~$ docker stack deploy -c docker-compose.yml getstartedlab
open docker-compose.yml: no such file or directory
docker@myvm1:~$ cd C:\Users\25386\Desktop\guide
-sh: cd: can't cd to C:Users25386Desktopguide
docker@myvm1:~$ ls
log.log
docker@myvm1:~$ ls
log.log
docker@myvm1:~$ exit
PS C:\Users\25386\Desktop\guide> docker-machine env myvm1
$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://192.168.43.89:2376"
$Env:DOCKER_CERT_PATH = "C:\MACHINE\machines\myvm1"
$Env:DOCKER_MACHINE_NAME = "myvm1"
$Env:COMPOSE_CONVERT_WINDOWS_PATHS = "true"
# Run this command to configure your shell:
# & "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env myvm1 |
Invoke-Expression
PS C:\Users\25386\Desktop\guide> docker-machine ssh myvm1 "docker node ls"
ID HOSTNAME STATUS AVAILABILITY
MANAGER STATUS
s5dbk3t9mx6yieb4zuqy8k6ja * myvm1 Ready Active
Leader
md9w91fg1apjco5bxz0gijxvu myvm2 Ready Active
PS C:\Users\25386\Desktop\guide> docker-machine env myvm2
$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://192.168.43.102:2376"
$Env:DOCKER_CERT_PATH = "C:\MACHINE\machines\myvm2"
$Env:DOCKER_MACHINE_NAME = "myvm2"
$Env:COMPOSE_CONVERT_WINDOWS_PATHS = "true"
# Run this command to configure your shell:
# & "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env myvm2 |
Invoke-Expression
PS C:\Users\25386\Desktop\guide> docker node ls
ID HOSTNAME STATUS AVAILABILITY
MANAGER STATUS
iwlvag90ftza9vmibuo80cx13 * moby Ready Active
Leader
PS C:\Users\25386\Desktop\guide> docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER
ERRORS
myvm1 - hyperv Running tcp://192.168.43.89:2376 v17.09.0-ce
myvm2 - hyperv Running tcp://192.168.43.102:2376 v17.09.0-ce
PS C:\Users\25386\Desktop\guide> docker node ls
ID HOSTNAME STATUS AVAILABILITY
MANAGER STATUS
iwlvag90ftza9vmibuo80cx13 * moby Ready Active
Leader
PS C:\Users\25386\Desktop\guide> docker node rm -f iwlvag90ftza9vmibuo80cx13
Error response from daemon: rpc error: code = FailedPrecondition desc = node
iwlvag90ftza9vmibuo80cx13 is a cluster manager and is a member o
f the raft cluster. It must be demoted to worker before removal
PS C:\Users\25386\Desktop\guide> docker node demote iwlvag90ftza9vmibuo80cx13
Error response from daemon: rpc error: code = FailedPrecondition desc = attempting
to demote the last manager of the swarm
PS C:\Users\25386\Desktop\guide> docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER
ERRORS
myvm1 - hyperv Running tcp://192.168.43.89:2376 v17.09.0-ce
myvm2 - hyperv Running tcp://192.168.43.102:2376 v17.09.0-ce
PS C:\Users\25386\Desktop\guide> docker-machine ssh myvm1 "docker node ls"
ID HOSTNAME STATUS AVAILABILITY
MANAGER STATUS
s5dbk3t9mx6yieb4zuqy8k6ja * myvm1 Ready Active
Leader
md9w91fg1apjco5bxz0gijxvu myvm2 Ready Active
PS C:\Users\25386\Desktop\guide> docker-machine ssh myvm1 "docker-machine ls"
sh: docker-machine: not found
PS C:\Users\25386\Desktop\guide> docker-machine active myvm1
Error: Too many arguments given
PS C:\Users\25386\Desktop\guide> docker-machine active
No active host found
PS C:\Users\25386\Desktop\guide> docker-machine myvm1
docker-machine.exe: 'myvm1' is not a docker-machine.exe command. See 'C:\Program
Files\Docker\Docker\Resources\bin\docker-machine.exe --help'
.
PS C:\Users\25386\Desktop\guide> & "C:\Program
Files\Docker\Docker\Resources\bin\docker-machine.exe" env myvm1 | Invoke-Expression
PS C:\Users\25386\Desktop\guide> docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER
ERRORS
myvm1 * hyperv Running tcp://192.168.43.89:2376 v17.09.0-ce
myvm2 - hyperv Running tcp://192.168.43.102:2376 v17.09.0-ce
PS C:\Users\25386\Desktop\guide> docker stack deploy -c docker-compose.yml
getstartedlab
Creating network getstartedlab_webnet
Creating service getstartedlab_web
PS C:\Users\25386\Desktop\guide> docker stack ps getstartedlab
ID NAME IMAGE NODE
DESIRED STATE CURRENT STATE ERROR
PORTS
qn2kyzmxye62 getstartedlab_web.1 xianchangjie/yj:v1 myvm2
Running Preparing 20 seconds ago

4hm9s3ptbw8j getstartedlab_web.2 xianchangjie/yj:v1 myvm1


Running Preparing 20 seconds ago

nx444x7q358d getstartedlab_web.3 xianchangjie/yj:v1 myvm2


Running Preparing 20 seconds ago

cv6wd4qhu34z getstartedlab_web.4 xianchangjie/yj:v1 myvm1


Running Preparing 20 seconds ago

22e6kkxidw4h getstartedlab_web.5 xianchangjie/yj:v1 myvm2


Running Preparing 20 seconds ago

kg51n51w2zb5 getstartedlab_web.6 xianchangjie/yj:v1 myvm1


Running Preparing 20 seconds ago

PS C:\Users\25386\Desktop\guide> docker service ls


ID NAME MODE REPLICAS
IMAGE PORTS
6q4g4yec8v0y getstartedlab_web replicated 6/6
xianchangjie/yj:v1 *:80->80/tcp
PS C:\Users\25386\Desktop\guide> docker service ps
"docker service ps" requires at least 1 argument.
See 'docker service ps --help'.

Usage: docker service ps [OPTIONS] SERVICE [SERVICE...]

List the tasks of one or more services


PS C:\Users\25386\Desktop\guide> docker stack ls
NAME SERVICES
getstartedlab 1
PS C:\Users\25386\Desktop\guide> docker stack ls getstartedlab
"docker stack ls" accepts no arguments.
See 'docker stack ls --help'.

Usage: docker stack ls

List stacks
PS C:\Users\25386\Desktop\guide> docker ps
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
4c93ddaacee9 xianchangjie/yj:v1 "python app.py" 4 minutes ago Up
3 minutes 80/tcp getstartedlab_web.4.
cv6wd4qhu34z7jgn5tec4s13h
2bf0c0d6405f xianchangjie/yj:v1 "python app.py" 4 minutes ago Up
3 minutes 80/tcp getstartedlab_web.2.
4hm9s3ptbw8jre9m32dw0op62
f6435a183bfb xianchangjie/yj:v1 "python app.py" 4 minutes ago Up
4 minutes 80/tcp getstartedlab_web.6.
kg51n51w2zb52950h54j9grg3
PS C:\Users\25386\Desktop\guide> docker ps
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
4c93ddaacee9 xianchangjie/yj:v1 "python app.py" 4 minutes ago Up
4 minutes 80/tcp getstartedlab_web.4.cv6wd4qhu34z7jgn5tec4s13h
2bf0c0d6405f xianchangjie/yj:v1 "python app.py" 4 minutes ago Up
4 minutes 80/tcp getstartedlab_web.2.4hm9s3ptbw8jre9m32dw0op62
f6435a183bfb xianchangjie/yj:v1 "python app.py" 4 minutes ago Up
4 minutes 80/tcp getstartedlab_web.6.kg51n51w2zb52950h54j9grg3
PS C:\Users\25386\Desktop\guide> docker ls
docker: 'ls' is not a docker command.
See 'docker --help'
PS C:\Users\25386\Desktop\guide> docker stack ls getstartedlab
"docker stack ls" accepts no arguments.
See 'docker stack ls --help'.

Usage: docker stack ls

List stacks
PS C:\Users\25386\Desktop\guide> docker stack ps getstartedlab
ID NAME IMAGE NODE
DESIRED STATE CURRENT STATE ERROR PORTS
qn2kyzmxye62 getstartedlab_web.1 xianchangjie/yj:v1 myvm2
Running Running 9 minutes ago
4hm9s3ptbw8j getstartedlab_web.2 xianchangjie/yj:v1 myvm1
Running Running 9 minutes ago
nx444x7q358d getstartedlab_web.3 xianchangjie/yj:v1 myvm2
Running Running 9 minutes ago
cv6wd4qhu34z getstartedlab_web.4 xianchangjie/yj:v1 myvm1
Running Running 9 minutes ago
22e6kkxidw4h getstartedlab_web.5 xianchangjie/yj:v1 myvm2
Running Running 9 minutes ago
kg51n51w2zb5 getstartedlab_web.6 xianchangjie/yj:v1 myvm1
Running Running 9 minutes ago
PS C:\Users\25386\Desktop\guide> docker-machine ssh myvm1 "docker node ls"
ID HOSTNAME STATUS AVAILABILITY
MANAGER STATUS
s5dbk3t9mx6yieb4zuqy8k6ja * myvm1 Ready Active
Leader
md9w91fg1apjco5bxz0gijxvu myvm2 Ready Active
PS C:\Users\25386\Desktop\guide>

Das könnte Ihnen auch gefallen