From be68cc8ac4b110a5859a366146ccdc844c7593df Mon Sep 17 00:00:00 2001 From: spiddy Date: Fri, 3 Jun 2016 10:50:01 +0200 Subject: [PATCH] added more steps on docker-machine workshop --- doc/01-docker-machine/readme.md | 74 ++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/doc/01-docker-machine/readme.md b/doc/01-docker-machine/readme.md index d5f855b..dd9dd44 100644 --- a/doc/01-docker-machine/readme.md +++ b/doc/01-docker-machine/readme.md @@ -16,7 +16,7 @@ The toolbox installs a handful of tools on your local Windows or Mac OS X comput Open a terminal on your computer. -Create and run a VM named `default`: +Create and run a VM named `default` using the following command: ``` docker-machine create -d virtualbox default @@ -28,8 +28,7 @@ You can list the existing docker-machines: docker-machine ls ``` - -Start the VM named `default`: +In case you already had the machine created, you can simply start the VM: ``` docker-machine start default @@ -41,7 +40,7 @@ Now, let's use the docker-machine we've just created. We want to run the `hello- If you use Mac, you need to run: ``` -eval $(docker machine env default) +eval $(docker-machine env default) ``` This command set the `DOCKER_HOST` variable to the IP of your `default` `docker-machine`. @@ -51,7 +50,6 @@ Then we can run the `hello-world` container: docker run hello-world ``` - ## Clean up After we tested our `default` `docker-machine` we want to remove it from our computer. @@ -68,6 +66,72 @@ You can destroy the VM named `default`: docker-machine rm default ``` +## Create two machines + +To create two machines do: + +``` +docker-machine create -d virtualbox client1 +docker-machine create -d virtualbox client2 +``` + +Now you can see the machines with: + +``` +docker-machine ls +``` + +## Run Nginx on client1 + +``` +eval $(docker-machine env client1) +docker run -d -p 80:80 nginx:1.8-alpine +docker-machine ip client1 +open "http://$(docker-machine ip client1)" +``` + +## Run Nginx on client2 + +``` +eval $(docker-machine env client2) +docker run -d -p 80:80 nginx:1.8-alpine +docker-machine ip client2 +open "http://$(docker-machine ip client2)" +``` + +## SSH to machine + +To SSH inside a machine: + +``` +docker-machine ssh client1 +``` + +## Environment variables + +Docker client is configured by environment variables to connect with remote daemons. The following command outputs the variables for connecting to previously created `default` VM. + +``` +docker-machine env default +``` + +## Active Machine + +To get the active machine's name do: + +``` +docker-machine active +``` + +## Cleanup + + +``` +docker-machine stop client1 client2 +docker-machine rm client1 client2 +``` + + # Navigation Previous | Next