1
0
Fork 0

Merge pull request #936 from funkyfuture/getting-started

Updates index.md 'Test it!' section
This commit is contained in:
Vincent Demeester 2016-12-08 18:39:04 +01:00 committed by GitHub
commit 686faf0556

View file

@ -34,7 +34,7 @@ Træfɪk can listen to your service registry/orchestrator API, and knows each ti
Routes to your services will be created instantly. Routes to your services will be created instantly.
Run it and forget it! Run it and forget it!
## Quickstart ## Quickstart
@ -70,39 +70,63 @@ 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'
image: traefik
command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /dev/null:/traefik.toml
whoami1: services:
image: emilevauge/whoami proxy:
labels: image: traefik
- "traefik.backend=whoami" command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
- "traefik.frontend.rule=Host:whoami.docker.localhost" networks:
- webgateway
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /dev/null:/traefik.toml
whoami2: networks:
image: emilevauge/whoami webgateway:
labels: driver: bridge
- "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