mirror of
https://github.com/docker/docs.git
synced 2026-03-27 06:18:55 +07:00
Addressed Windows issues with get started tutorial (#4675)
* how to get scp to work on Windows Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * clarified some commands in part 3 Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * fixed links on hyperv, machine pages Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * removing notes about scp and ssh on Windows, WIP Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * WIP: adding docker-machine env commands Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * added docker-machine env option, re-worked tabs Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * moved extra info re: docker-machine env out of note, to end of part 4 Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * updated parts 4, 5 with docker-machine env, added note re: commands Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * changed rest of ssh examples, formatting fixes, copyedit Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * copyedit on docker-machine env example Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * reworded note title Signed-off-by: Victoria Bialas <victoria.bialas@docker.com>
This commit is contained in:
@@ -155,22 +155,31 @@ Get the service ID for the one service in our application:
|
||||
docker service ls
|
||||
```
|
||||
|
||||
You'll see output for the `web` service, prepended with your app name. If you
|
||||
named it the same as shown in this example, the name will be
|
||||
`getstartedlab_web`. The service ID is listed as well, along with the number of
|
||||
replicas, image name, and exposed ports.
|
||||
|
||||
Docker swarms run tasks that spawn containers. Tasks have state and their own
|
||||
IDs:
|
||||
IDs. Let's list the tasks:
|
||||
|
||||
```shell
|
||||
docker service ps <service>
|
||||
```
|
||||
|
||||
>**Note**: Docker's support for swarms is built using a project called SwarmKit. SwarmKit tasks do not need to be containers, but Docker swarm tasks are defined to spawn them.
|
||||
>**Note**: Docker's support for swarms is built using a project
|
||||
called SwarmKit. SwarmKit tasks do not need to be containers, but
|
||||
Docker swarm tasks are defined to spawn them.
|
||||
|
||||
Let's inspect one task and limit the output to container ID:
|
||||
Let's inspect one of these tasks, and limit the output to container ID:
|
||||
|
||||
```shell
|
||||
docker inspect --format='{% raw %}{{.Status.ContainerStatus.ContainerID}}{% endraw %}' <task>
|
||||
```
|
||||
|
||||
Vice versa, inspect the container ID, and extract the task ID:
|
||||
Vice versa, you can inspect a container ID, and extract the task ID.
|
||||
|
||||
First run `docker container ls` to get container IDs, then:
|
||||
|
||||
```shell
|
||||
docker inspect --format="{% raw %}{{index .Config.Labels \"com.docker.swarm.task.id\"}}{% endraw %}" <container>
|
||||
@@ -185,7 +194,7 @@ docker container ls -q
|
||||
You can run `curl http://localhost` several times in a row, or go to that URL in
|
||||
your browser and hit refresh a few times. Either way, you'll see the container
|
||||
ID change, demonstrating the load-balancing; with each request, one of
|
||||
the 5 replicas is chosen, in a round-robin fashion, to respond.
|
||||
the 5 replicas is chosen, in a round-robin fashion, to respond. The container IDs will match your output from the previous command (`docker container ls -q`).
|
||||
|
||||
|
||||
>**Note**: At this stage, it may take up to 30 seconds for the containers to respond to HTTP
|
||||
|
||||
@@ -66,15 +66,100 @@ enables the use of swarms. Enabling swarm mode instantly makes the current
|
||||
machine a swarm manager. From then on, Docker will run the commands you execute
|
||||
on the swarm you're managing, rather than just on the current machine.
|
||||
|
||||
{% capture local-instructions %}
|
||||
You now have two VMs created, named `myvm1` and `myvm2`:
|
||||
## Set up your swarm
|
||||
|
||||
A swarm is made up of multiple nodes, which can be either physical or virtual
|
||||
machines. The basic concept is simple enough: run `docker swarm init` to enable
|
||||
swarm mode and make your current machine a swarm manager, then run
|
||||
`docker swarm join` on other machines to have them join the swarm as workers.
|
||||
Choose a tab below to see how this plays out in various contexts. We'll use VMs
|
||||
to quickly create a two-machine cluster and turn it into a swarm.
|
||||
|
||||
### Create a cluster
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#local">Local VMs (Mac, Linux, Windows 7 and 8)</a></li>
|
||||
<li><a data-toggle="tab" href="#localwin">Local VMs (Windows 10/Hyper-V)</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div id="local" class="tab-pane fade in active">
|
||||
{% capture local-content %}
|
||||
|
||||
#### VMs on your local machine (Mac, Linux, Windows 7 and 8)
|
||||
|
||||
First, you'll need a hypervisor that can create virtual machines (VMs), so
|
||||
[install Oracle VirtualBox](https://www.virtualbox.org/wiki/Downloads) for your
|
||||
machine's OS.
|
||||
|
||||
> **Note**: If you are on a Windows system that has Hyper-V installed,
|
||||
such as Windows 10, there is no need to install VirtualBox and you should
|
||||
use Hyper-V instead. View the instructions for Hyper-V systems by clicking
|
||||
the Hyper-V tab above. If you are using
|
||||
[Docker Toolbox](/toolbox/overview.md), you should already have
|
||||
VirtualBox installed as part of it, so you are good to go.
|
||||
|
||||
Now, create a couple of VMs using `docker-machine`, using the VirtualBox driver:
|
||||
|
||||
```shell
|
||||
docker-machine create --driver virtualbox myvm1
|
||||
docker-machine create --driver virtualbox myvm2
|
||||
```
|
||||
|
||||
{% endcapture %}
|
||||
{{ local-content | markdownify }}
|
||||
|
||||
</div>
|
||||
<div id="localwin" class="tab-pane fade" markdown="1">
|
||||
{% capture localwin-content %}
|
||||
|
||||
#### VMs on your local machine (Windows 10)
|
||||
|
||||
First, quickly create a virtual switch for your virtual machines (VMs) to share,
|
||||
so they will be able to connect to each other.
|
||||
|
||||
1. Launch Hyper-V Manager
|
||||
2. Click **Virtual Switch Manager** in the right-hand menu
|
||||
3. Click **Create Virtual Switch** of type **External**
|
||||
4. Give it the name `myswitch`, and check the box to share your host machine's
|
||||
active network adapter
|
||||
|
||||
Now, create a couple of VMs using our node management tool,
|
||||
`docker-machine`:
|
||||
|
||||
```shell
|
||||
docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1
|
||||
docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm2
|
||||
```
|
||||
|
||||
{% endcapture %}
|
||||
{{ localwin-content | markdownify }}
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
#### List the VMs and get their IP addresses
|
||||
|
||||
You now have two VMs created, named `myvm1` and `myvm2`.
|
||||
|
||||
Use this command to list the machines and get their IP addresses.
|
||||
|
||||
```shell
|
||||
docker-machine ls
|
||||
```
|
||||
|
||||
The first one will act as the manager, which executes management commands and
|
||||
authenticates workers to join the swarm, and the second will be a worker.
|
||||
Here is example output from this command.
|
||||
|
||||
```shell
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
|
||||
myvm1 - virtualbox Running tcp://192.168.99.100:2376 v17.06.2-ce
|
||||
myvm2 - virtualbox Running tcp://192.168.99.101:2376 v17.06.2-ce
|
||||
```
|
||||
|
||||
#### Initialze the swarm and add nodes
|
||||
|
||||
The first machine will act as the manager, which executes management commands
|
||||
and authenticates workers to join the swarm, and the second will be a worker.
|
||||
|
||||
You can send commands to your VMs using `docker-machine ssh`. Instruct `myvm1`
|
||||
to become a swarm manager with `docker swarm init` and you'll see output like
|
||||
@@ -93,15 +178,15 @@ To add a worker to this swarm, run the following command:
|
||||
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
|
||||
```
|
||||
|
||||
> **Note**: Ports 2376 and 2377
|
||||
> Port 2376 is the Docker daemon port. Port 2377 is the swarm management port.
|
||||
> Run `docker swarm init` and `docker swarm join` with port 2377 or no port at
|
||||
> all.
|
||||
> Ports 2377 and 2376
|
||||
>
|
||||
> Always run `docker swarm init` and `docker swarm join` with port 2377
|
||||
> (the swarm management port), or no port at all and let it take the default.
|
||||
>
|
||||
> The machine IP addresses returned by `docker-machine ls` include port 2376,
|
||||
> which is the Docker daemon port. Do not use this port or
|
||||
> [you may experience errors](https://forums.docker.com/t/docker-swarm-join-with-virtualbox-connection-error-13-bad-certificate/31392/2).
|
||||
|
||||
> The VM URLs returned by`docker-machine ls` include port 2376. Do not use this
|
||||
> port or [you may experience errors](https://forums.docker.com/t/docker-swarm-join-with-virtualbox-connection-error-13-bad-certificate/31392/2).
|
||||
|
||||
> To start over, run `docker swarm leave` from each node.
|
||||
|
||||
As you can see, the response to `docker swarm init` contains a pre-configured
|
||||
`docker swarm join` command for you to run on any nodes you want to add. Copy
|
||||
@@ -116,126 +201,153 @@ $ docker-machine ssh myvm2 "docker swarm join \
|
||||
This node joined a swarm as a worker.
|
||||
```
|
||||
|
||||
Congratulations, you have created your first swarm.
|
||||
Congratulations, you have created your first swarm!
|
||||
|
||||
> **Note**: You can also run `docker-machine ssh myvm1` with no command attached
|
||||
to open a terminal session on that VM. Type `exit` when you're ready to return
|
||||
to the host shell prompt. It may be easier to paste the join command in that
|
||||
way.
|
||||
|
||||
Use `ssh` to connect to the (`docker-machine ssh myvm1`), and run `docker node ls` to view the nodes in this swarm:
|
||||
Run `docker node ls` on the manager to view the nodes in this swarm:
|
||||
|
||||
```shell
|
||||
docker@myvm1:~$ docker node ls
|
||||
$ docker-machine ssh myvm1 "docker node ls"
|
||||
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
|
||||
brtu9urxwfd5j0zrmkubhpkbd myvm2 Ready Active
|
||||
rihwohkh3ph38fhillhhb84sk * myvm1 Ready Active Leader
|
||||
```
|
||||
|
||||
Type `exit` to get back out of that machine.
|
||||
> Leaving a swarm
|
||||
>
|
||||
> If you want to start over, you can run `docker swarm leave` from each node.
|
||||
|
||||
Alternatively, wrap commands in `docker-machine ssh` to keep from having to directly log in and out. For example:
|
||||
|
||||
```shell
|
||||
docker-machine ssh myvm1 "docker node ls"
|
||||
```
|
||||
|
||||
|
||||
{% endcapture %}
|
||||
|
||||
{% capture local %}
|
||||
#### VMs on your local machine (Mac, Linux, Windows 7 and 8)
|
||||
|
||||
First, you'll need a hypervisor that can create VMs, so [install
|
||||
VirtualBox](https://www.virtualbox.org/wiki/Downloads) for your machine's OS.
|
||||
|
||||
> **Note**: If you're on a Windows system that has Hyper-V installed, such as
|
||||
Windows 10, there is no need to install VirtualBox and you should use Hyper-V
|
||||
instead. View the instructions for Hyper-V systems by clicking the Hyper-V tab
|
||||
above.
|
||||
|
||||
Now, create a couple of VMs using `docker-machine`, using the VirtualBox driver:
|
||||
|
||||
```none
|
||||
$ docker-machine create --driver virtualbox myvm1
|
||||
$ docker-machine create --driver virtualbox myvm2
|
||||
```
|
||||
|
||||
{{ local-instructions }}
|
||||
{% endcapture %}
|
||||
|
||||
{% capture localwin %}
|
||||
#### VMs on your local machine (Windows 10)
|
||||
|
||||
First, quickly create a virtual switch for your VMs to share, so they will be
|
||||
able to connect to each other.
|
||||
|
||||
1. Launch Hyper-V Manager
|
||||
2. Click **Virtual Switch Manager** in the right-hand menu
|
||||
3. Click **Create Virtual Switch** of type **External**
|
||||
4. Give it the name `myswitch`, and check the box to share your host machine's
|
||||
active network adapter
|
||||
|
||||
Now, create a couple of virtual machines using our node management tool,
|
||||
`docker-machine`:
|
||||
|
||||
```shell
|
||||
$ docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1
|
||||
$ docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm2
|
||||
```
|
||||
|
||||
{{ local-instructions }}
|
||||
{% endcapture %}
|
||||
|
||||
## Set up your swarm
|
||||
|
||||
A swarm is made up of multiple nodes, which can be either physical or virtual
|
||||
machines. The basic concept is simple enough: run `docker swarm init` to enable
|
||||
swarm mode and make your current machine a swarm manager, then run
|
||||
`docker swarm join` on other machines to have them join the swarm as workers.
|
||||
Choose a tab below to see how this plays out in various contexts. We'll use VMs
|
||||
to quickly create a two-machine cluster and turn it into a swarm.
|
||||
|
||||
### Create a cluster
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#local">Local VMs (Mac, Linux, Windows 7 and 8)</a></li>
|
||||
<li><a data-toggle="tab" href="#localwin">Local VMs (Windows 10/Hyper-V)</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div id="local" class="tab-pane fade in active" markdown="1">{{ local }}</div>
|
||||
<div id="localwin" class="tab-pane fade" markdown="1">{{ localwin }}</div>
|
||||
</div>
|
||||
|
||||
## Deploy your app on a cluster
|
||||
## Deploy your app on the swarm cluster
|
||||
|
||||
The hard part is over. Now you just repeat the process you used in [part
|
||||
3](part3.md) to deploy on your new swarm. Just remember that only swarm managers
|
||||
like `myvm1` execute Docker commands; workers are just for capacity.
|
||||
|
||||
Copy the file `docker-compose.yml` you created in part 3 to the swarm manager
|
||||
`myvm1`'s home directory (alias: `~`) by using the `docker-machine scp` command:
|
||||
### Configure a `docker-machine` shell to the swarm manager
|
||||
|
||||
```
|
||||
docker-machine scp docker-compose.yml myvm1:~
|
||||
So far, you've been wrapping Docker commmands in `docker-machine ssh` to talk to
|
||||
the VMs. Another option is to run `docker-machine env <machine>` to get
|
||||
and run a command that configures your current shell to talk to the Docker
|
||||
daemon on the VM. This method works better for the next step because it allows
|
||||
you to use your local `docker-compose.yml` file to deploy the app
|
||||
"remotely" without having to copy it anywhere.
|
||||
|
||||
Type `docker-machine env myvm1`, then copy-paste and run the command provided as
|
||||
the last line of the output to configure your shell to talk to `myvm1`, the
|
||||
swarm manager.
|
||||
|
||||
The commands to configure your shell differ depending on whether you are Mac,
|
||||
Linux, or Windows, so examples of each are shown on the tabs below.
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#mac-linux-machine">Mac, Linux</a></li>
|
||||
<li><a data-toggle="tab" href="#win-machine">Windows</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div id="mac-linux-machine" class="tab-pane fade in active">
|
||||
{% capture mac-linux-machine-content %}
|
||||
|
||||
#### Docker machine shell environment on Mac or Linux
|
||||
|
||||
Run `docker-machine env myvm1` to get the command to configure your shell to
|
||||
talk to `myvm1`.
|
||||
|
||||
```shell
|
||||
$ docker-machine env myvm1
|
||||
export DOCKER_TLS_VERIFY="1"
|
||||
export DOCKER_HOST="tcp://192.168.99.100:2376"
|
||||
export DOCKER_CERT_PATH="/Users/sam/.docker/machine/machines/myvm1"
|
||||
export DOCKER_MACHINE_NAME="myvm1"
|
||||
# Run this command to configure your shell:
|
||||
# eval $(docker-machine env myvm1)
|
||||
```
|
||||
|
||||
Now have `myvm1` use its powers as a swarm manager to deploy your app, by sending
|
||||
the same `docker stack deploy` command you used in part 3 to `myvm1` using
|
||||
`docker-machine ssh`:
|
||||
Run the given command to configure your shell to talk to `myvm1`.
|
||||
|
||||
```
|
||||
docker-machine ssh myvm1 "docker stack deploy -c docker-compose.yml getstartedlab"
|
||||
```shell
|
||||
eval $(docker-machine env myvm1)
|
||||
```
|
||||
|
||||
And that's it, the app is deployed on a cluster.
|
||||
Run `docker-machine ls` to verify that `myvm1` is now the active machine, as
|
||||
indicated by the asterisk next to it.
|
||||
|
||||
Wrap all the commands you used in part 3 in a call to `docker-machine ssh`, and
|
||||
they'll all work as you'd expect. Only this time, you'll see that the containers
|
||||
have been distributed between both `myvm1` and `myvm2`.
|
||||
```shell
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
|
||||
myvm1 * virtualbox Running tcp://192.168.99.100:2376 v17.06.2-ce
|
||||
myvm2 - virtualbox Running tcp://192.168.99.101:2376 v17.06.2-ce
|
||||
```
|
||||
|
||||
{% endcapture %}
|
||||
{{ mac-linux-machine-content | markdownify }}
|
||||
|
||||
</div>
|
||||
<div id="win-machine" class="tab-pane fade">
|
||||
{% capture win-machine-content %}
|
||||
|
||||
#### Docker machine shell environment on Windows
|
||||
|
||||
Run `docker-machine env myvm1` to get the command to configure your shell to
|
||||
talk to `myvm1`.
|
||||
|
||||
```shell
|
||||
PS C:\Users\sam\sandbox\get-started> docker-machine env myvm1
|
||||
$Env:DOCKER_TLS_VERIFY = "1"
|
||||
$Env:DOCKER_HOST = "tcp://192.168.203.207:2376"
|
||||
$Env:DOCKER_CERT_PATH = "C:\Users\sam\.docker\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
|
||||
```
|
||||
|
||||
Run the given command to configure your shell to talk to `myvm1`.
|
||||
|
||||
```shell
|
||||
& "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env myvm1 | Invoke-Expression
|
||||
```
|
||||
|
||||
Run `docker-machine ls` to verify that `myvm1` is the active machine as indicated by the asterisk next to it.
|
||||
|
||||
```shell
|
||||
PS C:PATH> docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
|
||||
myvm1 * hyperv Running tcp://192.168.203.207:2376 v17.06.2-ce
|
||||
myvm2 - hyperv Running tcp://192.168.200.181:2376 v17.06.2-ce
|
||||
```
|
||||
|
||||
{% endcapture %}
|
||||
{{ win-machine-content | markdownify }}
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
### Deploy the app on the swarm manager
|
||||
|
||||
Now that you have my `myvm1`, you can use its powers as a swarm manager to
|
||||
deploy your app by using the same `docker stack deploy` command you used in part
|
||||
3 to `myvm1`, and your local copy of `docker-stack.yml.`
|
||||
|
||||
You are connected to `myvm1` by means of the `docker-machine` shell
|
||||
configuration, and you still have access to the files on your local host. Make
|
||||
sure you are in the same directory as before, which includes the
|
||||
[`docker-compose.yml` file you created in part
|
||||
3](/get-started/part3/#docker-composeyml).
|
||||
|
||||
Just like before, run the following command to deploy the app on `myvm1`.
|
||||
|
||||
```
|
||||
$ docker-machine ssh myvm1 "docker stack ps getstartedlab"
|
||||
docker stack deploy -c docker-compose.yml getstartedlab
|
||||
```
|
||||
|
||||
And that's it, the app is deployed on a swarm cluster!
|
||||
|
||||
Now you can use the same [docker commands you used in part
|
||||
3](/get-started/part3.md#run-your-new-load-balanced-app). Only this time you'll
|
||||
see that the containers have been distributed between both `myvm1` and `myvm2`.
|
||||
|
||||
|
||||
```
|
||||
$ docker stack ps getstartedlab
|
||||
|
||||
ID NAME IMAGE NODE DESIRED STATE
|
||||
jq2g3qp8nzwx test_web.1 username/repo:tag myvm1 Running
|
||||
@@ -245,6 +357,27 @@ ghii74p9budx test_web.4 username/repo:tag myvm1 Running
|
||||
0prmarhavs87 test_web.5 username/repo:tag myvm2 Running
|
||||
```
|
||||
|
||||
> Connecting to VMs with `docker-machine env` and `docker-machine ssh`
|
||||
>
|
||||
> * To set your shell to talk to a different machine like `myvm2`, simply re-run
|
||||
`docker-machine env` in the same or a different shell, then run the given
|
||||
command to point to `myvm2`. This is always specific to the current shell. If
|
||||
you change to an unconfigured shell or open a new one, you need to re-run the
|
||||
commands. Use `docker-machine ls` to list machines, see what state they are in,
|
||||
get IP addresses, and find out which one, if any, you are connected to. To learn
|
||||
more, see the [Docker Machine getting started topics](/machine/get-started.md#create-a-machine).
|
||||
>
|
||||
> * Alternatively, you can wrap Docker commands in the form of
|
||||
`docker-machine ssh <machine> "<command>"`, which logs directly into
|
||||
the VM but doesn't give you immediate access to files on your local host.
|
||||
>
|
||||
> * On Mac and Linux, you can use `docker-machine scp <file> <machine>:~`
|
||||
to copy files across machines, but Windows users need a terminal emulator
|
||||
like [Git Bash](https://git-for-windows.github.io/){: target="_blank" class="_"} in order for this to work.
|
||||
>
|
||||
> This tutorial demos both `docker-machine ssh` and
|
||||
`docker-machine env`, since these are available on all platforms via the `docker-machine` CLI.
|
||||
|
||||
### Accessing your cluster
|
||||
|
||||
You can access your app from the IP address of **either** `myvm1` or `myvm2`.
|
||||
@@ -292,7 +425,7 @@ take advantage of the new resources.
|
||||
You can tear down the stack with `docker stack rm`. For example:
|
||||
|
||||
```
|
||||
docker-machine ssh myvm1 "docker stack rm getstartedlab"
|
||||
docker stack rm getstartedlab
|
||||
```
|
||||
|
||||
> Keep the swarm or remove it?
|
||||
@@ -307,7 +440,8 @@ docker-machine ssh myvm1 "docker stack rm getstartedlab"
|
||||
|
||||
## Recap and cheat sheet (optional)
|
||||
|
||||
Here's [a terminal recording of what was covered on this page](https://asciinema.org/a/113837):
|
||||
Here's [a terminal recording of what was covered on this
|
||||
page](https://asciinema.org/a/113837):
|
||||
|
||||
<script type="text/javascript" src="https://asciinema.org/a/113837.js" id="asciicast-113837" speed="2" async></script>
|
||||
|
||||
|
||||
@@ -107,17 +107,17 @@ with the following. Be sure to replace `username/repo:tag` with your image detai
|
||||
|
||||
We'll talk more about placement constraints and volumes in a moment.
|
||||
|
||||
2. Copy this new `docker-compose.yml` file to the swarm manager, `myvm1`:
|
||||
2. Make sure your shell is configured to talk to `myvm1` (examples are [here](part4.md#configure-a-docker-machine-shell-to-the-swarm-manager)).
|
||||
|
||||
```shell
|
||||
docker-machine scp docker-compose.yml myvm1:~
|
||||
```
|
||||
* Run `docker-machine ls` to list machines and make sure you are connected to `myvm1`, as indicated by an asterisk next it.
|
||||
|
||||
* If needed, re-run `docker-machine env myvm1`, then run the given command to configure the shell.
|
||||
|
||||
3. Re-run the `docker stack deploy` command on the manager, and
|
||||
whatever services need updating will be updated:
|
||||
|
||||
```shell
|
||||
$ docker-machine ssh myvm1 "docker stack deploy -c docker-compose.yml getstartedlab"
|
||||
$ docker stack deploy -c docker-compose.yml getstartedlab
|
||||
Updating service getstartedlab_web (id: angi1bf5e4to03qu9f93trnxm)
|
||||
Updating service getstartedlab_visualizer (id: l9mnwkeq2jiononb5ihz9u7a4)
|
||||
```
|
||||
@@ -135,7 +135,7 @@ whatever services need updating will be updated:
|
||||
corroborate this visualization by running `docker stack ps <stack>`:
|
||||
|
||||
```shell
|
||||
docker-machine ssh myvm1 "docker stack ps getstartedlab"
|
||||
docker stack ps getstartedlab
|
||||
```
|
||||
|
||||
The visualizer is a standalone service that can run in any app
|
||||
@@ -229,19 +229,19 @@ Redis service. Be sure to replace `username/repo:tag` with your image details.
|
||||
2. Create a `./data` directory on the manager:
|
||||
|
||||
```shell
|
||||
$ docker-machine ssh myvm1 "mkdir ./data"
|
||||
docker-machine ssh myvm1 "mkdir ./data"
|
||||
```
|
||||
|
||||
3. Copy over the new `docker-compose.yml` file with `docker-machine scp`:
|
||||
3. Make sure your shell is configured to talk to `myvm1` (examples are [here](part4.md#configure-a-docker-machine-shell-to-the-swarm-manager)).
|
||||
|
||||
```shell
|
||||
$ docker-machine scp docker-compose.yml myvm1:~
|
||||
```
|
||||
* Run `docker-machine ls` to list machines and make sure you are connected to `myvm1`, as indicated by an asterisk next it.
|
||||
|
||||
* If needed, re-run `docker-machine env myvm1`, then run the given command to configure the shell.
|
||||
|
||||
4. Run `docker stack deploy` one more time.
|
||||
|
||||
```shell
|
||||
$ docker-machine ssh myvm1 "docker stack deploy -c docker-compose.yml getstartedlab"
|
||||
docker stack deploy -c docker-compose.yml getstartedlab
|
||||
```
|
||||
|
||||
5. Check the web page at one of your nodes (e.g. `http://192.168.99.101`) and you'll see the results of the visitor counter, which is now live and storing information on Redis.
|
||||
|
||||
@@ -100,10 +100,9 @@ menus](/docker-cloud/cloud-swarm/connect-to-swarm.md#use-docker-for-mac-or-windo
|
||||
|
||||
Either way, this opens a terminal whose context is your local machine, but whose
|
||||
Docker commands are routed up to the swarm running on your cloud service
|
||||
provider. This is a little different from the paradigm you've been following,
|
||||
where you were sending commands via SSH. Now, you can directly access both your
|
||||
local file system and your remote swarm, enabling some very tidy-looking
|
||||
commands:
|
||||
provider. This is the same shell configuration method you've already learned
|
||||
with `docker-machine env`. You directly access both your local file system and
|
||||
your remote swarm, enabling pure `docker` commands:
|
||||
|
||||
```shell
|
||||
docker stack deploy -c docker-compose.yml getstartedlab
|
||||
|
||||
@@ -93,39 +93,40 @@ networked host
|
||||
machines](/engine/swarm/swarm-tutorial/index.md#three-networked-host-machines),
|
||||
you can create these swarm nodes: `manager1`, `worker1`, `worker2`.
|
||||
|
||||
* Use the Microsoft Hyper-V driver and reference the new virtual switch you created.
|
||||
|
||||
docker-machine create -d hyperv --hyperv-virtual-switch "<NameOfVirtualSwitch>" <nameOfNode>
|
||||
* Use the Microsoft Hyper-V driver and reference the new virtual switch you created.
|
||||
|
||||
```shell
|
||||
docker-machine create -d hyperv --hyperv-virtual-switch "<NameOfVirtualSwitch>" <nameOfNode>
|
||||
```
|
||||
|
||||
Here is an example of creating `manager1` node:
|
||||
|
||||
```shell
|
||||
PS C:\WINDOWS\system32> docker-machine create -d hyperv --hyperv-virtual-switch "Primary Virtual Switch" manager1
|
||||
Running pre-create checks...
|
||||
Creating machine...
|
||||
(manager1) Copying C:\Users\Vicky\.docker\machine\cache\boot2docker.iso to C:\Users\Vicky\.docker\machine\machines\manag
|
||||
er1\boot2docker.iso...
|
||||
(manager1) Creating SSH key...
|
||||
(manager1) Creating VM...
|
||||
(manager1) Using switch "Primary Virtual Switch"
|
||||
(manager1) Creating VHD
|
||||
(manager1) Starting VM...
|
||||
(manager1) 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\Doc
|
||||
ker\Docker\Resources\bin\docker-machine.exe env manager1
|
||||
PS C:\WINDOWS\system32>
|
||||
```
|
||||
|
||||
```shell
|
||||
PS C:\WINDOWS\system32> docker-machine create -d hyperv --hyperv-virtual-switch "Primary Virtual Switch" manager1
|
||||
Running pre-create checks...
|
||||
Creating machine...
|
||||
(manager1) Copying C:\Users\Vicky\.docker\machine\cache\boot2docker.iso to C:\Users\Vicky\.docker\machine\machines\manag
|
||||
er1\boot2docker.iso...
|
||||
(manager1) Creating SSH key...
|
||||
(manager1) Creating VM...
|
||||
(manager1) Using switch "Primary Virtual Switch"
|
||||
(manager1) Creating VHD
|
||||
(manager1) Starting VM...
|
||||
(manager1) 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\Doc
|
||||
ker\Docker\Resources\bin\docker-machine.exe env manager1
|
||||
PS C:\WINDOWS\system32>
|
||||
```
|
||||
* Use the same process, driver, and network switch to create the other nodes.
|
||||
|
||||
For our example, the commands will look like this:
|
||||
|
||||
@@ -46,7 +46,7 @@ The prerequisites are:
|
||||
|
||||
* Set up the Hyper-V driver to use an external virtual network switch See
|
||||
the [Docker Machine driver for Microsoft Hyper-V](drivers/hyper-v.md) topic,
|
||||
which includes an /machine/drivers/hyper-v.md#example of how to do this.
|
||||
which includes an [example](/machine/drivers/hyper-v.md#example) of how to do this.
|
||||
|
||||
#### If you are using Docker for Mac
|
||||
|
||||
|
||||
7
test.md
7
test.md
@@ -91,9 +91,12 @@ https://github.com/docker/docker.github.io/tree/master/docker-cloud/images
|
||||
|
||||
#### Using a custom target ID
|
||||
This topic has a custom target ID above its heading that can be used to link to
|
||||
it, in addtion to, or instead of, the default concatenated heading style.
|
||||
it, in addtion to, or instead of, the default concatenated heading style. The
|
||||
format of this ID is `{: id="custom-target-id"}`.
|
||||
|
||||
You can use custom targets to link to headings or even paragraphs.
|
||||
You can use custom targets to link to headings or even paragraphs. You link to
|
||||
it as you would any other link, using `#custom-target-id` as the ultimate
|
||||
target.
|
||||
|
||||
An example of a custom target ID in the documentation is the topic on
|
||||
[Compose file version 2 topic on CPU and other resources](/compose/compose-file/compose-file-v2.md#cpu-and-other-resources).
|
||||
|
||||
Reference in New Issue
Block a user