Update install-w-machine.md

This commit is contained in:
John Mulhausen 2016-10-24 18:23:58 -07:00 committed by GitHub
parent 550463cd4b
commit d17c2039f2
1 changed files with 76 additions and 47 deletions

View File

@ -37,15 +37,17 @@ Daemon running on each node. Other discovery service backends such as
1. List the machines on your system. 1. List the machines on your system.
```bash
$ docker-machine ls $ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM NAME ACTIVE DRIVER STATE URL SWARM
docker-vm * virtualbox Running tcp://192.168.99.100:2376 docker-vm * virtualbox Running tcp://192.168.99.100:2376
```
This example was run a macOS system with Docker Toolbox installed. So, the This example was run a macOS system with Docker Toolbox installed. So, the `docker-vm` virtual machine is in the list.
`docker-vm` virtual machine is in the list.
2. Create a VirtualBox machine called `local` on your system. 2. Create a VirtualBox machine called `local` on your system.
```bash
$ docker-machine create -d virtualbox local $ docker-machine create -d virtualbox local
INFO[0000] Creating SSH key... INFO[0000] Creating SSH key...
INFO[0000] Creating VirtualBox VM... INFO[0000] Creating VirtualBox VM...
@ -53,10 +55,13 @@ Daemon running on each node. Other discovery service backends such as
INFO[0005] Waiting for VM to start... INFO[0005] Waiting for VM to start...
INFO[0050] "local" has been created and is now the active machine. INFO[0050] "local" has been created and is now the active machine.
INFO[0050] To point your Docker client at it, run this in your shell: eval "$(docker-machine env local)" INFO[0050] To point your Docker client at it, run this in your shell: eval "$(docker-machine env local)"
```
3. Load the `local` machine configuration into your shell. 3. Load the `local` machine configuration into your shell.
```
$ eval "$(docker-machine env local)" $ eval "$(docker-machine env local)"
```
4. Generate a discovery token using the Docker Swarm image. 4. Generate a discovery token using the Docker Swarm image.
@ -64,6 +69,7 @@ Daemon running on each node. Other discovery service backends such as
haven't got the `swarm:latest` image on your local machine, Docker pulls it haven't got the `swarm:latest` image on your local machine, Docker pulls it
for you. for you.
```
$ docker run swarm create $ docker run swarm create
Unable to find image 'swarm:latest' locally Unable to find image 'swarm:latest' locally
latest: Pulling from swarm latest: Pulling from swarm
@ -78,6 +84,7 @@ Daemon running on each node. Other discovery service backends such as
Digest: sha256:aaaf6c18b8be01a75099cc554b4fb372b8ec677ae81764dcdf85470279a61d6f Digest: sha256:aaaf6c18b8be01a75099cc554b4fb372b8ec677ae81764dcdf85470279a61d6f
Status: Downloaded newer image for swarm:latest Status: Downloaded newer image for swarm:latest
fe0cc96a72cf04dba8c1c4aa79536ec3 fe0cc96a72cf04dba8c1c4aa79536ec3
```
The `swarm create` command returned the `fe0cc96a72cf04dba8c1c4aa79536ec3` The `swarm create` command returned the `fe0cc96a72cf04dba8c1c4aa79536ec3`
token. token.
@ -105,15 +112,18 @@ In this section, you create a swarm manager and two nodes.
1. Create a swarm manager under VirtualBox. 1. Create a swarm manager under VirtualBox.
```
docker-machine create \ docker-machine create \
-d virtualbox \ -d virtualbox \
--swarm \ --swarm \
--swarm-master \ --swarm-master \
--swarm-discovery token://<TOKEN-FROM-ABOVE> \ --swarm-discovery token://<TOKEN-FROM-ABOVE> \
swarm-master swarm-master
```
For example: For example:
```
$ docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://fe0cc96a72cf04dba8c1c4aa79536ec3 swarm-master $ docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://fe0cc96a72cf04dba8c1c4aa79536ec3 swarm-master
INFO[0000] Creating SSH key... INFO[0000] Creating SSH key...
INFO[0000] Creating VirtualBox VM... INFO[0000] Creating VirtualBox VM...
@ -121,22 +131,28 @@ In this section, you create a swarm manager and two nodes.
INFO[0005] Waiting for VM to start... INFO[0005] Waiting for VM to start...
INFO[0060] "swarm-master" has been created and is now the active machine. INFO[0060] "swarm-master" has been created and is now the active machine.
INFO[0060] To point your Docker client at it, run this in your shell: eval "$(docker-machine env swarm-master)" INFO[0060] To point your Docker client at it, run this in your shell: eval "$(docker-machine env swarm-master)"
```
2. Open your VirtualBox Manager, it should contain the `local` machine and the 2. Open your VirtualBox Manager, it should contain the `local` machine and the
new `swarm-master` machine. new `swarm-master` machine.
```
![VirtualBox](images/virtual-box.png) ![VirtualBox](images/virtual-box.png)
```
3. Create a swarm node. 3. Create a swarm node.
```bash
docker-machine create \ docker-machine create \
-d virtualbox \ -d virtualbox \
--swarm \ --swarm \
--swarm-discovery token://<TOKEN-FROM-ABOVE> \ --swarm-discovery token://<TOKEN-FROM-ABOVE> \
swarm-agent-00 swarm-agent-00
```
For example: For example:
```bash
$ docker-machine create -d virtualbox --swarm --swarm-discovery token://fe0cc96a72cf04dba8c1c4aa79536ec3 swarm-agent-00 $ docker-machine create -d virtualbox --swarm --swarm-discovery token://fe0cc96a72cf04dba8c1c4aa79536ec3 swarm-agent-00
INFO[0000] Creating SSH key... INFO[0000] Creating SSH key...
INFO[0000] Creating VirtualBox VM... INFO[0000] Creating VirtualBox VM...
@ -144,10 +160,13 @@ new `swarm-master` machine.
INFO[0006] Waiting for VM to start... INFO[0006] Waiting for VM to start...
INFO[0066] "swarm-agent-00" has been created and is now the active machine. INFO[0066] "swarm-agent-00" has been created and is now the active machine.
INFO[0066] To point your Docker client at it, run this in your shell: eval "$(docker-machine env swarm-agent-00)" INFO[0066] To point your Docker client at it, run this in your shell: eval "$(docker-machine env swarm-agent-00)"
```
3. Add another agent called `swarm-agent-01`. 3. Add another agent called `swarm-agent-01`.
```bash
$ docker-machine create -d virtualbox --swarm --swarm-discovery token://fe0cc96a72cf04dba8c1c4aa79536ec3 swarm-agent-01 $ docker-machine create -d virtualbox --swarm --swarm-discovery token://fe0cc96a72cf04dba8c1c4aa79536ec3 swarm-agent-01
```
You should see the two agents in your VirtualBox Manager. You should see the two agents in your VirtualBox Manager.
@ -159,11 +178,14 @@ your swarm, and start an image on your swarm.
1. Point your Docker environment to the machine running the swarm master. 1. Point your Docker environment to the machine running the swarm master.
```bash
$ eval $(docker-machine env --swarm swarm-master) $ eval $(docker-machine env --swarm swarm-master)
```
2. Get information on your new swarm using the `docker` command. 2. Get information on your new swarm using the `docker` command.
```bash
$ docker info $ docker info
Containers: 4 Containers: 4
Strategy: spread Strategy: spread
@ -180,6 +202,7 @@ your swarm, and start an image on your swarm.
swarm-master: 192.168.99.104:2376 swarm-master: 192.168.99.104:2376
└ Containers: 2 └ Containers: 2
└ Reserved CPUs: 0 / 8 └ Reserved CPUs: 0 / 8
```
You can see that each agent and the master all have port `2376` exposed. When you create a swarm, you can use any port you like and even different ports on different nodes. Each swarm node runs the swarm agent container. You can see that each agent and the master all have port `2376` exposed. When you create a swarm, you can use any port you like and even different ports on different nodes. Each swarm node runs the swarm agent container.
@ -187,15 +210,18 @@ your swarm, and start an image on your swarm.
3. Check the images currently running on your swarm. 3. Check the images currently running on your swarm.
```bash
$ docker ps -a $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
78be991b58d1 swarm:latest "/swarm join --addr 3 minutes ago Up 2 minutes 2375/tcp swarm-agent-01/swarm-agent 78be991b58d1 swarm:latest "/swarm join --addr 3 minutes ago Up 2 minutes 2375/tcp swarm-agent-01/swarm-agent
da5127e4f0f9 swarm:latest "/swarm join --addr 6 minutes ago Up 6 minutes 2375/tcp swarm-agent-00/swarm-agent da5127e4f0f9 swarm:latest "/swarm join --addr 6 minutes ago Up 6 minutes 2375/tcp swarm-agent-00/swarm-agent
ef395f316c59 swarm:latest "/swarm join --addr 16 minutes ago Up 16 minutes 2375/tcp swarm-master/swarm-agent ef395f316c59 swarm:latest "/swarm join --addr 16 minutes ago Up 16 minutes 2375/tcp swarm-master/swarm-agent
45821ca5208e swarm:latest "/swarm manage --tls 16 minutes ago Up 16 minutes 2375/tcp, 192.168.99.104:3376->3376/tcp swarm-master/swarm-agent-master 45821ca5208e swarm:latest "/swarm manage --tls 16 minutes ago Up 16 minutes 2375/tcp, 192.168.99.104:3376->3376/tcp swarm-master/swarm-agent-master
```
4. Run the Docker `hello-world` test image on your swarm. 4. Run the Docker `hello-world` test image on your swarm.
```bash
$ docker run hello-world $ docker run hello-world
Hello from Docker. Hello from Docker.
This message shows that your installation appears to be working correctly. This message shows that your installation appears to be working correctly.
@ -208,16 +234,19 @@ your swarm, and start an image on your swarm.
executable that produces the output you are currently reading. executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it 4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal. to your terminal.
```
To try something more ambitious, you can run an Ubuntu container with: To try something more ambitious, you can run an Ubuntu container with:
```bash
$ docker run -it ubuntu bash $ docker run -it ubuntu bash
```
For more examples and ideas, visit: For more examples and ideas, visit the [User Guide](http://docs.docker.com/userguide/).
http://docs.docker.com/userguide/
5. Use the `docker ps` command to find out which node the container ran on. 5. Use the `docker ps` command to find out which node the container ran on.
```bash
$ docker ps -a $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
54a8690043dd hello-world:latest "/hello" 22 seconds ago Exited (0) 3 seconds ago swarm-agent-00/modest_goodall 54a8690043dd hello-world:latest "/hello" 22 seconds ago Exited (0) 3 seconds ago swarm-agent-00/modest_goodall
@ -225,7 +254,7 @@ http://docs.docker.com/userguide/
da5127e4f0f9 swarm:latest "/swarm join --addr 8 minutes ago Up 8 minutes 2375/tcp swarm-agent-00/swarm-agent da5127e4f0f9 swarm:latest "/swarm join --addr 8 minutes ago Up 8 minutes 2375/tcp swarm-agent-00/swarm-agent
ef395f316c59 swarm:latest "/swarm join --addr 18 minutes ago Up 18 minutes 2375/tcp swarm-master/swarm-agent ef395f316c59 swarm:latest "/swarm join --addr 18 minutes ago Up 18 minutes 2375/tcp swarm-master/swarm-agent
45821ca5208e swarm:latest "/swarm manage --tls 18 minutes ago Up 18 minutes 2375/tcp, 192.168.99.104:3376->3376/tcp swarm-master/swarm-agent-master 45821ca5208e swarm:latest "/swarm manage --tls 18 minutes ago Up 18 minutes 2375/tcp, 192.168.99.104:3376->3376/tcp swarm-master/swarm-agent-master
```
## Where to go next ## Where to go next