This is a bare minimum guide to try traefik with Docker.
port = ":80"
[web]
address = ":8080"
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "docker.local"
watch = true
docker run -d \
-p 80:80 \
-p 8080:8080 \
-v $PWD/traefik.toml:/traefik.toml \
-v /var/run/docker.sock:/var/run/docker.sock \
emilevauge/traefik
Example 1
docker run -d \
-v /path/to/my/content:/content \
-p 8081:80 \
--name app1 \
larsks/thttpd -d /content
You can acces this as app1.docker.local (You'd have to point docker.local to 127.0.0.1 in /etc/hosts file)
Example 2
docker run -d \
--label=traefik.frontend.rule=Host:app2.dev \
-v /path/to/my/content:/content \
-p 8082:80 \
larsks/thttpd -d /content
You can access this as app2.dev (You need to update /etc/hosts)
Having to add all .dev or .docker.local domains to /etc/hosts is a pain. You can easily do that with dnsmasq.
sudo apt-get install dnsmasq
Now append address=/dev/127.0.0.1
and address=/docker.local/127.0.0.1
to /etc/dnsmasq.conf and restart dnsmasq
sudo service dnsmasq restart
Now all *.dev and *.docker.local domains will be pointed to 127.0.0.1, which in our case will be handled by Traefik.
PS: Use .test
instead of .dev
just because.
Adding address=/dev/127.0.0.1 on etc/dnsmasq.conf doesnt seem to work for me.
Are there any good ways to debug+