Skip to content

Commit f8710ad

Browse files
authored
Merge pull request docker#56 from ManoMarks/master
Updating beginer tutorial
2 parents e517036 + cf38200 commit f8710ad

File tree

10 files changed

+29
-175
lines changed

10 files changed

+29
-175
lines changed

beginner/chapters/setup.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ There are no specific skills needed for this tutorial beyond a basic comfort wit
66
### Setting up your computer
77
Getting all the tooling setup on your computer can be a daunting task, but getting Docker up and running on your favorite OS has become very easy.
88

9-
The *getting started* guide on Docker has detailed instructions for setting up Docker on [Mac](https://docs.docker.com/docker-for-mac/), [Linux](https://docs.docker.com/engine/installation/linux/) and [Windows](https://docs.docker.com/docker-for-windows/).
9+
The *getting started* guide on Docker has detailed instructions for setting up Docker on [Mac](https://docs.docker.com/docker-for-mac/), [Linux](https://docs.docker.com/engine/installation/linux/) and [Windows](https://docs.docker.com/docker-for-windows/).
10+
11+
*If you're using Docker for Windows* make sure you have [shared your drive](https://docs.docker.com/docker-for-windows/#/shared-drives).
1012

1113
*Important note* If you're using an older version of Windows or MacOS you may need to use [Docker Machine](https://docs.docker.com/machine/overview/) instead.
1214

15+
*All commandline work in either bash or Powershell on Windows*
16+
1317
Once you are done installing Docker, test your Docker installation by running the following:
1418
```
1519
$ docker run hello-world

beginner/chapters/votingapp.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ In the folder ```example-voting-app/voting-app``` you need to edit the app.py an
3333
Edit the following lines:
3434

3535
```
36-
option_a = os.getenv('OPTION_A', "Java")
37-
option_b = os.getenv('OPTION_B', "Python")
36+
option_a = os.getenv('OPTION_A', "Cats")
37+
option_b = os.getenv('OPTION_B', "Dogs")
3838
```
3939

4040
substituting two options of your choice. For instance:
4141

4242
```
43-
option_a = os.getenv('OPTION_A', "Cats")
44-
option_b = os.getenv('OPTION_B', "Dogs")
43+
option_a = os.getenv('OPTION_A', "Java")
44+
option_b = os.getenv('OPTION_B', ".NET")
4545
```
4646
#### 3.2.2 Running your app
4747
Now, run your application. To do that, we'll use [Docker Compose](https://docs.docker.com/compose). Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you define a `.yml` file that describes all the containers and volumes that you want, and the networks between them. In the example-voting-app directory, you'll see a `docker-compose.yml file`:
@@ -71,9 +71,7 @@ services:
7171
- back-tier
7272

7373
worker:
74-
image: manomarks/worker
75-
networks:
76-
- back-tier
74+
build: ./worker
7775

7876
redis:
7977
image: redis:alpine
@@ -103,10 +101,10 @@ This Compose file defines
103101
- A voting-app container based on a Python image
104102
- A result-app container based on a Node.js image
105103
- A redis container based on a redis image, to temporarily store the data.
106-
- A Java based worker app based on a Java image
104+
- A .NET based worker app based on a .NET image
107105
- A Postgres container based on a postgres image
108106
109-
Note that three of the containers are built from Dockerfiles, while the other two are images on Docker Hub. To learn more about how they're built, you can examine each of the Dockerfiles in the two directories: `voting-app`, `result-app`. We included the code for the Java worker in `worker` but pre-built the image to save on downloads.
107+
Note that three of the containers are built from Dockerfiles, while the other two are images on Docker Hub. To learn more about how they're built, you can examine each of the Dockerfiles in the three directories: `vote`, `result`, `worker`.
110108

111109
The Compose file also defines two networks, front-tier and back-tier. Each container is placed on one or two networks. Once on those networks, they can access other services on that network in code just by using the name of the service. To learn more about networking check out the [Networking with Compose documentation](https://docs.docker.com/compose/networking/).
112110

beginner/chapters/webapps.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ Now that you've seen how to run a webserver inside a Docker image, how do you cr
8989
But first, let's stop and remove the containers since you won't be using them anymore.
9090

9191
```
92-
$ docker stop static-site static-site
93-
$ docker rm static-site static-site
92+
$ docker stop static-site
93+
$ docker rm static-site
9494
```
9595

9696
Let's use a shortcut to remove the second site:

swarm-mode/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
[Docker Swarm Mode](https://docs.docker.com/engine/swarm/) is a release candidate feature included with Docker Engine 1.12. These tutorials are designed to help you quickly get started testing these new features.
44

55
* [Docker Swarm Mode full tutorial](beginner-tutorial/README.md)
6-
* [Swarm quickstart tutorial](quickstart/README.md)
7-
* [Service deployment on a swarm](beginner/README.md)
6+
* [Service deployment on a swarm in the Cloud](cloud-quick-start/README.md)

swarm-mode/beginner-tutorial/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,5 @@ Successfully removed manager3
382382
```
383383

384384
## Next steps
385-
Next, check out the documentation on [Docker Swarm Mode](https://docs.docker.com/engine/swarm/) for more information.
385+
We have a similar tutorial using Docker Machine to do [Service deployment on a swarm in the Cloud](../cloud-quick-start/README.md).
386+
Also check out the documentation on [Docker Swarm Mode](https://docs.docker.com/engine/swarm/) for more information.

swarm-mode/beginner/README.md renamed to swarm-mode/cloud-quick-start/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Service deployment on a swarm
1+
# Service deployment on a swarm in the Cloud
22

33
Script that create a swarm cluster and deploy a simple service.
44
Swarm is created with Swarm mode of Engine 1.12. Can be created on

swarm-mode/beginner/swarm.sh renamed to swarm-mode/cloud-quick-start/swarm.sh

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
# This will run in bash on Linux, Mac, and Windows 10 Anniverary Edition
12
# Default cluster:
23
# - 3 manager node
34
# - 5 worker nodes
45
# - 5 replicas for the test service
56
# - service image: ehazlett/docker-demo
67
# - service port: 8080 (port exposed by the service)
78
# - exposed port: 8080 (port exposed to the outside)
9+
810
DRIVER="virtualbox"
911
NBR_MANAGER=3
1012
NBR_WORKER=5
@@ -82,7 +84,7 @@ while [ "$#" -gt 0 ]; do
8284
--azure-subscription-id)
8385
AZURE_SUBSCRIPTION_ID="$2"
8486
shift 2
85-
;;
87+
;;
8688
-h|--help)
8789
usage
8890
;;
@@ -116,7 +118,7 @@ if [ "$DRIVER" == "amazonec2" ];then
116118
if [ "$EC2_SECURITY_GROUP" == "" ];then
117119
error "--amazonec2-security-group must be provided (+ make sure this one allows inter hosts communication and is has opened port $EXPOSED_PORT to the outside"
118120
fi
119-
PERMISSION="sudo"
121+
PERMISSION="sudo"
120122
ADDITIONAL_PARAMS="--amazonec2-access-key ${EC2_ACCESS_KEY} --amazonec2-secret-key ${EC2_SECRET_KEY} --amazonec2-security-group ${EC2_SECURITY_GROUP} --amazonec2-security-group docker-machine --amazonec2-region eu-west-1 --amazonec2-instance-type t2.micro --amazonec2-ami ami-f95ef58a --engine-install-url=https://test.docker.com"
121123
echo "-> about to create a swarm with $NBR_MANAGER manager(s) and $NBR_WORKER workers on $DRIVER machines (eu-west-1 / t2.micro / Ubuntu 14.04)"
122124
fi
@@ -126,12 +128,12 @@ if [ "$DRIVER" == "azure" ];then
126128
if [ "$AZURE_SUBSCRIPTION_ID" == "" ];then
127129
error "--azure-subscription-id must be provided"
128130
fi
129-
# For Azure Storage Container the Manager and Worker prefix must be lowercase
131+
# For Azure Storage Container the Manager and Worker prefix must be lowercase
130132
PREFIX=$(date "+%Y%m%dt%H%M%S")
131133
MANAGER=${PREFIX}-manager
132134
WORKER=${PREFIX}-worker
133135

134-
PERMISSION="sudo"
136+
PERMISSION="sudo"
135137
ADDITIONAL_PARAMS="--driver azure --azure-subscription-id ${AZURE_SUBSCRIPTION_ID} --azure-open-port ${EXPOSED_PORT}"
136138
echo "-> about to create a swarm with $NBR_MANAGER manager(s) and $NBR_WORKER workers on $DRIVER machines (westus / Standard_A2 / Ubuntu 15.10)"
137139
fi
@@ -153,7 +155,7 @@ function getIP {
153155
echo $(docker-machine inspect -f '{{ .Driver.PrivateIPAddress }}' $1)
154156
elif [ "$DRIVER" == "azure" ]; then
155157
echo $(docker-machine ssh $1 ifconfig eth0 | awk '/inet addr/{print substr($2,6)}')
156-
else
158+
else
157159
echo $(docker-machine inspect -f '{{ .Driver.IPAddress }}' $1)
158160
fi
159161
}
@@ -176,10 +178,10 @@ function get_worker_token {
176178
function create_manager {
177179
for i in $(seq 1 $NBR_MANAGER); do
178180
echo "-> creating Docker host for manager $i (please wait)"
179-
# Azure needs Stdout for authentication. Workaround: Show Stdout on first Manager.
181+
# Azure needs Stdout for authentication. Workaround: Show Stdout on first Manager.
180182
if [ "$DRIVER" == "azure" ] && [ "$i" -eq 1 ];then
181183
docker-machine create --driver $DRIVER $ADDITIONAL_PARAMS ${MANAGER}$i
182-
else
184+
else
183185
docker-machine create --driver $DRIVER $ADDITIONAL_PARAMS ${MANAGER}$i 1>/dev/null
184186
fi
185187
done
@@ -204,7 +206,7 @@ function join_other_managers {
204206
if [ "$((NBR_MANAGER-1))" -ge "1" ];then
205207
for i in $(seq 2 $NBR_MANAGER);do
206208
echo "-> ${MANAGER}$i requests membership to the swarm"
207-
docker-machine ssh ${MANAGER}$i $PERMISSION docker swarm join --token $(get_manager_token) --listen-addr $(getIP ${MANAGER}$i):2377 --advertise-addr $(getIP ${MANAGER}$i):2377 $(getIP ${MANAGER}1):2377 2>&1
209+
docker-machine ssh ${MANAGER}$i $PERMISSION docker swarm join --token $(get_manager_token) --listen-addr $(getIP ${MANAGER}$i):2377 --advertise-addr $(getIP ${MANAGER}$i):2377 $(getIP ${MANAGER}1):2377 2>&1
208210
done
209211
fi
210212
}
@@ -249,7 +251,7 @@ function status {
249251
echo "-> list tasks"
250252
echo
251253
docker-machine ssh ${MANAGER}1 $PERMISSION docker service ps demo
252-
echo
254+
echo
253255
echo "-> list machines"
254256
docker-machine ls | egrep $PREFIX
255257
echo

swarm-mode/quickstart/README.md

-43
This file was deleted.

swarm-mode/quickstart/buildswarm-do.sh

-33
This file was deleted.

swarm-mode/quickstart/buildswarm-vbox.sh

-74
This file was deleted.

0 commit comments

Comments
 (0)