Updates index.md 'Test it!' section
adapted to current schema for compose files uses networks as necessary in a real world usage
This commit is contained in:
parent
c500873586
commit
fe2d4e0d38
1 changed files with 48 additions and 24 deletions
|
@ -70,12 +70,17 @@ docker run -d -p 8080:8080 -p 80:80 -v $PWD/traefik.toml:/etc/traefik/traefik.to
|
||||||
|
|
||||||
## Test it
|
## Test it
|
||||||
|
|
||||||
You can test Træfɪk easily using [Docker compose](https://docs.docker.com/compose), with this `docker-compose.yml` file:
|
You can test Træfɪk easily using [Docker compose](https://docs.docker.com/compose), with this `docker-compose.yml` file in a folder named `traefik`:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
traefik:
|
version: '2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
proxy:
|
||||||
image: traefik
|
image: traefik
|
||||||
command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
|
command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
|
||||||
|
networks:
|
||||||
|
- webgateway
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
|
@ -83,26 +88,45 @@ traefik:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- /dev/null:/traefik.toml
|
- /dev/null:/traefik.toml
|
||||||
|
|
||||||
whoami1:
|
networks:
|
||||||
image: emilevauge/whoami
|
webgateway:
|
||||||
labels:
|
driver: bridge
|
||||||
- "traefik.backend=whoami"
|
|
||||||
- "traefik.frontend.rule=Host:whoami.docker.localhost"
|
|
||||||
|
|
||||||
whoami2:
|
|
||||||
image: emilevauge/whoami
|
|
||||||
labels:
|
|
||||||
- "traefik.backend=whoami"
|
|
||||||
- "traefik.frontend.rule=Host:whoami.docker.localhost"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, start it:
|
Start it from within the `traefik` folder:
|
||||||
|
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
In a browser you may open `http://localhost:8080` to access Træfɪk's dashboard and observe the following magic.
|
||||||
|
|
||||||
|
Now, create a folder named `test` and create a `docker-compose.yml` in it with this content:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
whoami:
|
||||||
|
image: emilevauge/whoami
|
||||||
|
networks:
|
||||||
|
- web
|
||||||
|
labels:
|
||||||
|
- "traefik.backend=whoami"
|
||||||
|
- "traefik.frontend.rule=Host:whoami.docker.localhost"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
web:
|
||||||
|
external:
|
||||||
|
name: traefik_webgateway
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, start and scale it in the `test` folder:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
docker-compose scale whoami=2
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, test load-balancing between the two servers `whoami1` and `whoami2`:
|
Finally, test load-balancing between the two services `test_whoami_1` and `test_whoami_2`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ curl -H Host:whoami.docker.localhost http://127.0.0.1
|
$ curl -H Host:whoami.docker.localhost http://127.0.0.1
|
||||||
|
|
Loading…
Reference in a new issue