A localhost Traefik Playground
This is a local playground to help you get started with Traefik. If you speak German listen to our Episode where we talk about this setup and discuss Traefik.
You can use this setup to experiment with Traefik and also easily host services on your machine without remembering lots of ports. Domain names are much more intuitive. Also your browser will help you auto-complete domains better than port numbers.
git clone https://github.com/codeandship/traefik-playground.git cd traefik-playground
Edit your /etc/hosts file
sudo nano /etc/hosts
Append these lines at the end:
127.0.0.1 traefik.docker.localhost 127.0.0.1 web.docker.localhost 127.0.0.1 readme.docker.localhost
This is a poor man's DNS solution but it works very reliable. If you want to add domains later do not forget to add them to your
Running the Playground
How does it work?
Traefik connects to the Docker Daemon to read labels from running containers. All containers that are connected to the network
traefik-playground_default are also reachable from the Traefik container. Traefik is able to reverse proxy requests based on the lables assigned to docker containers.
If your working directory from where you executed
docker-compose up is not
traefik-playground the network name is different.
Adding a container / domain
You can either edit the
docker-compose.yml file inside this repository or connect a container to the proxy network. Either way you have to tell Traefik via lables how to serve the web port of this container.
127.0.0.1 project.docker.localhost to
project with something that better describes your project).
Run the project container:
docker run \ --name some-project \ -d \ --network traefik-playground_default \ -l "traefik.http.routers.project.rule=Host(\`project.docker.localhost\`)" \ someimage
HTTPS, specific ports and more
Read this blog post from the makers of Traefik.
Rebuild README.md to HTML