Skip to content

Commit

Permalink
Merge pull request docker#56 from ManoMarks/master
Browse files Browse the repository at this point in the history
Updating beginer tutorial
  • Loading branch information
spara authored Sep 23, 2016
2 parents e517036 + cf38200 commit f8710ad
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 175 deletions.
6 changes: 5 additions & 1 deletion beginner/chapters/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ There are no specific skills needed for this tutorial beyond a basic comfort wit
### Setting up your computer
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.

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/).
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/).

*If you're using Docker for Windows* make sure you have [shared your drive](https://docs.docker.com/docker-for-windows/#/shared-drives).

*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.

*All commandline work in either bash or Powershell on Windows*

Once you are done installing Docker, test your Docker installation by running the following:
```
$ docker run hello-world
Expand Down
16 changes: 7 additions & 9 deletions beginner/chapters/votingapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ In the folder ```example-voting-app/voting-app``` you need to edit the app.py an
Edit the following lines:

```
option_a = os.getenv('OPTION_A', "Java")
option_b = os.getenv('OPTION_B', "Python")
option_a = os.getenv('OPTION_A', "Cats")
option_b = os.getenv('OPTION_B', "Dogs")
```

substituting two options of your choice. For instance:

```
option_a = os.getenv('OPTION_A', "Cats")
option_b = os.getenv('OPTION_B', "Dogs")
option_a = os.getenv('OPTION_A', "Java")
option_b = os.getenv('OPTION_B', ".NET")
```
#### 3.2.2 Running your app
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`:
Expand Down Expand Up @@ -71,9 +71,7 @@ services:
- back-tier

worker:
image: manomarks/worker
networks:
- back-tier
build: ./worker

redis:
image: redis:alpine
Expand Down Expand Up @@ -103,10 +101,10 @@ This Compose file defines
- A voting-app container based on a Python image
- A result-app container based on a Node.js image
- A redis container based on a redis image, to temporarily store the data.
- A Java based worker app based on a Java image
- A .NET based worker app based on a .NET image
- A Postgres container based on a postgres image
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.
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`.

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/).

Expand Down
4 changes: 2 additions & 2 deletions beginner/chapters/webapps.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ Now that you've seen how to run a webserver inside a Docker image, how do you cr
But first, let's stop and remove the containers since you won't be using them anymore.

```
$ docker stop static-site static-site
$ docker rm static-site static-site
$ docker stop static-site
$ docker rm static-site
```

Let's use a shortcut to remove the second site:
Expand Down
3 changes: 1 addition & 2 deletions swarm-mode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
[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.

* [Docker Swarm Mode full tutorial](beginner-tutorial/README.md)
* [Swarm quickstart tutorial](quickstart/README.md)
* [Service deployment on a swarm](beginner/README.md)
* [Service deployment on a swarm in the Cloud](cloud-quick-start/README.md)
3 changes: 2 additions & 1 deletion swarm-mode/beginner-tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,4 +382,5 @@ Successfully removed manager3
```

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

Script that create a swarm cluster and deploy a simple service.
Swarm is created with Swarm mode of Engine 1.12. Can be created on
Expand Down
20 changes: 11 additions & 9 deletions swarm-mode/beginner/swarm.sh → swarm-mode/cloud-quick-start/swarm.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# This will run in bash on Linux, Mac, and Windows 10 Anniverary Edition
# Default cluster:
# - 3 manager node
# - 5 worker nodes
# - 5 replicas for the test service
# - service image: ehazlett/docker-demo
# - service port: 8080 (port exposed by the service)
# - exposed port: 8080 (port exposed to the outside)

DRIVER="virtualbox"
NBR_MANAGER=3
NBR_WORKER=5
Expand Down Expand Up @@ -82,7 +84,7 @@ while [ "$#" -gt 0 ]; do
--azure-subscription-id)
AZURE_SUBSCRIPTION_ID="$2"
shift 2
;;
;;
-h|--help)
usage
;;
Expand Down Expand Up @@ -116,7 +118,7 @@ if [ "$DRIVER" == "amazonec2" ];then
if [ "$EC2_SECURITY_GROUP" == "" ];then
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"
fi
PERMISSION="sudo"
PERMISSION="sudo"
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"
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)"
fi
Expand All @@ -126,12 +128,12 @@ if [ "$DRIVER" == "azure" ];then
if [ "$AZURE_SUBSCRIPTION_ID" == "" ];then
error "--azure-subscription-id must be provided"
fi
# For Azure Storage Container the Manager and Worker prefix must be lowercase
# For Azure Storage Container the Manager and Worker prefix must be lowercase
PREFIX=$(date "+%Y%m%dt%H%M%S")
MANAGER=${PREFIX}-manager
WORKER=${PREFIX}-worker

PERMISSION="sudo"
PERMISSION="sudo"
ADDITIONAL_PARAMS="--driver azure --azure-subscription-id ${AZURE_SUBSCRIPTION_ID} --azure-open-port ${EXPOSED_PORT}"
echo "-> about to create a swarm with $NBR_MANAGER manager(s) and $NBR_WORKER workers on $DRIVER machines (westus / Standard_A2 / Ubuntu 15.10)"
fi
Expand All @@ -153,7 +155,7 @@ function getIP {
echo $(docker-machine inspect -f '{{ .Driver.PrivateIPAddress }}' $1)
elif [ "$DRIVER" == "azure" ]; then
echo $(docker-machine ssh $1 ifconfig eth0 | awk '/inet addr/{print substr($2,6)}')
else
else
echo $(docker-machine inspect -f '{{ .Driver.IPAddress }}' $1)
fi
}
Expand All @@ -176,10 +178,10 @@ function get_worker_token {
function create_manager {
for i in $(seq 1 $NBR_MANAGER); do
echo "-> creating Docker host for manager $i (please wait)"
# Azure needs Stdout for authentication. Workaround: Show Stdout on first Manager.
# Azure needs Stdout for authentication. Workaround: Show Stdout on first Manager.
if [ "$DRIVER" == "azure" ] && [ "$i" -eq 1 ];then
docker-machine create --driver $DRIVER $ADDITIONAL_PARAMS ${MANAGER}$i
else
else
docker-machine create --driver $DRIVER $ADDITIONAL_PARAMS ${MANAGER}$i 1>/dev/null
fi
done
Expand All @@ -204,7 +206,7 @@ function join_other_managers {
if [ "$((NBR_MANAGER-1))" -ge "1" ];then
for i in $(seq 2 $NBR_MANAGER);do
echo "-> ${MANAGER}$i requests membership to the swarm"
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
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
done
fi
}
Expand Down Expand Up @@ -249,7 +251,7 @@ function status {
echo "-> list tasks"
echo
docker-machine ssh ${MANAGER}1 $PERMISSION docker service ps demo
echo
echo
echo "-> list machines"
docker-machine ls | egrep $PREFIX
echo
Expand Down
43 changes: 0 additions & 43 deletions swarm-mode/quickstart/README.md

This file was deleted.

33 changes: 0 additions & 33 deletions swarm-mode/quickstart/buildswarm-do.sh

This file was deleted.

74 changes: 0 additions & 74 deletions swarm-mode/quickstart/buildswarm-vbox.sh

This file was deleted.

0 comments on commit f8710ad

Please sign in to comment.