Skip to content

Commit f93c790

Browse files
committed
Merge pull request #6 from harbur/docker-machine-tutorial
added more steps on docker-machine workshop
2 parents 3b1a3d4 + be68cc8 commit f93c790

File tree

1 file changed

+69
-5
lines changed

1 file changed

+69
-5
lines changed

doc/01-docker-machine/readme.md

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The toolbox installs a handful of tools on your local Windows or Mac OS X comput
1616

1717
Open a terminal on your computer.
1818

19-
Create and run a VM named `default`:
19+
Create and run a VM named `default` using the following command:
2020

2121
```
2222
docker-machine create -d virtualbox default
@@ -28,8 +28,7 @@ You can list the existing docker-machines:
2828
docker-machine ls
2929
```
3030

31-
32-
Start the VM named `default`:
31+
In case you already had the machine created, you can simply start the VM:
3332

3433
```
3534
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-
4140

4241
If you use Mac, you need to run:
4342
```
44-
eval $(docker machine env default)
43+
eval $(docker-machine env default)
4544
```
4645

4746
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:
5150
docker run hello-world
5251
```
5352

54-
5553
## Clean up
5654

5755
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`:
6866
docker-machine rm default
6967
```
7068

69+
## Create two machines
70+
71+
To create two machines do:
72+
73+
```
74+
docker-machine create -d virtualbox client1
75+
docker-machine create -d virtualbox client2
76+
```
77+
78+
Now you can see the machines with:
79+
80+
```
81+
docker-machine ls
82+
```
83+
84+
## Run Nginx on client1
85+
86+
```
87+
eval $(docker-machine env client1)
88+
docker run -d -p 80:80 nginx:1.8-alpine
89+
docker-machine ip client1
90+
open "http://$(docker-machine ip client1)"
91+
```
92+
93+
## Run Nginx on client2
94+
95+
```
96+
eval $(docker-machine env client2)
97+
docker run -d -p 80:80 nginx:1.8-alpine
98+
docker-machine ip client2
99+
open "http://$(docker-machine ip client2)"
100+
```
101+
102+
## SSH to machine
103+
104+
To SSH inside a machine:
105+
106+
```
107+
docker-machine ssh client1
108+
```
109+
110+
## Environment variables
111+
112+
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.
113+
114+
```
115+
docker-machine env default
116+
```
117+
118+
## Active Machine
119+
120+
To get the active machine's name do:
121+
122+
```
123+
docker-machine active
124+
```
125+
126+
## Cleanup
127+
128+
129+
```
130+
docker-machine stop client1 client2
131+
docker-machine rm client1 client2
132+
```
133+
134+
71135
# Navigation
72136

73137
Previous | Next

0 commit comments

Comments
 (0)