From ebd500a989a8e79aaf65ece0944fecb24dcc6221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Posp=C3=AD=C5=A1ek?= Date: Thu, 20 Jun 2019 17:40:26 +0200 Subject: [PATCH 1/3] add docker-compose example and fix some paths --- slides.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/slides.md b/slides.md index 5e842aa..62ee735 100644 --- a/slides.md +++ b/slides.md @@ -477,7 +477,7 @@ drwxr-xr-x 22 root root 4096 Sep 22 13:24 .. ~/apache2-build$ mkdir html ~/apache2-build$ echo 'Docker world' > html/index.html -$ cat Dockerfile +~/apache2-build$ cat Dockerfile FROM ubuntu:14.04 RUN apt-get update -yqq @@ -501,7 +501,7 @@ CMD ["-D", "FOREGROUND"] Anhand einer Baubeschreibung (Dockerfile) ein Image aufbauen. *** ```bash -$ docker build -t infrabricks/apache2 . +~/apache2-build$ docker build -t infrabricks/apache2 . Sending build context to Docker daemon 249.4 MB Sending build context to Docker daemon Step 0 : FROM ubuntu:14.04 @@ -665,7 +665,85 @@ N1_NAME=/n2/n1 * Skaliert nicht. (Was wenn ich 2x N1 habe?) * Abhängigkeiten nicht dynamisch (Wenn N1 neu, dann muss auch N2 neu) --- +**`$ docker-compose
`** +#### Applikationen aus mehreren Containern + + * Ausführliche Version siehe: https://docs.docker.com/compose/gettingstarted/ + * Code aus https://github.com/vegasbrianc/docker-compose-demo/blob/master/app.py + +*** +```bash +$ sudo apt-get install docker-compose +``` +*** + +*** +```bash +$ mkdir composetest +$ cd composetest +``` +*** + +Datei `app.py` erstellen: + +*** +```python +from redis import Redis +from flask import Flask + +app = Flask(__name__) +redis = Redis(host='redis', port=6379) + +@app.route('/') +def hello(): + redis.incr('hits') + return 'Hello World! I have been seen %s times.\n' % redis.get('hits') +``` +*** + +`requirements.txt` erstellen: + +*** +```bash +flask +redis +``` +*** + +`Dockerfile` für Web Applikation erstellen: + +*** +```Dockerfile +FROM python:3.7-alpine +WORKDIR /code +ENV FLASK_APP app.py +ENV FLASK_RUN_HOST 0.0.0.0 +RUN apk add --no-cache gcc musl-dev linux-headers +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt +COPY . . +CMD ["flask", "run"] +``` +*** + +`docker-compose.yml` erstellen: + +*** +```YAML +version: '3' +services: + web: + build: . + ports: + - "5000:5000" + redis: + image: "redis:alpine" +``` +*** +--- + Würde gerne als Abspann die noch fehlenden Kommandos kurz erläutern! + --- ## * Nach dem Link sollten wir ein Beispiel mit einer Gruppe von Container machen! From 4da139289a6ad9880a87f83e1c3ffe89f0cfd46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Posp=C3=AD=C5=A1ek?= Date: Thu, 20 Jun 2019 18:00:45 +0200 Subject: [PATCH 2/3] improve formatting --- slides.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/slides.md b/slides.md index 62ee735..797c31d 100644 --- a/slides.md +++ b/slides.md @@ -671,13 +671,10 @@ N1_NAME=/n2/n1 * Ausführliche Version siehe: https://docs.docker.com/compose/gettingstarted/ * Code aus https://github.com/vegasbrianc/docker-compose-demo/blob/master/app.py -*** ```bash $ sudo apt-get install docker-compose ``` -*** -*** ```bash $ mkdir composetest $ cd composetest @@ -686,7 +683,6 @@ $ cd composetest Datei `app.py` erstellen: -*** ```python from redis import Redis from flask import Flask @@ -699,11 +695,9 @@ def hello(): redis.incr('hits') return 'Hello World! I have been seen %s times.\n' % redis.get('hits') ``` -*** `requirements.txt` erstellen: -*** ```bash flask redis @@ -712,7 +706,6 @@ redis `Dockerfile` für Web Applikation erstellen: -*** ```Dockerfile FROM python:3.7-alpine WORKDIR /code @@ -724,11 +717,9 @@ RUN pip install -r requirements.txt COPY . . CMD ["flask", "run"] ``` -*** `docker-compose.yml` erstellen: -*** ```YAML version: '3' services: @@ -739,6 +730,11 @@ services: redis: image: "redis:alpine" ``` + +```bash +~composetest$ docker-compose up` +``` + *** --- From e6d3a6b45f1ee47744459e7de51dac65698ddff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Posp=C3=AD=C5=A1ek?= Date: Thu, 20 Jun 2019 18:03:29 +0200 Subject: [PATCH 3/3] inserted title --- slides.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/slides.md b/slides.md index 797c31d..3385978 100644 --- a/slides.md +++ b/slides.md @@ -665,6 +665,8 @@ N1_NAME=/n2/n1 * Skaliert nicht. (Was wenn ich 2x N1 habe?) * Abhängigkeiten nicht dynamisch (Wenn N1 neu, dann muss auch N2 neu) --- +## Docker-Compose + **`$ docker-compose
`** #### Applikationen aus mehreren Containern