I'm having troubles getting a basic Traefik routing setup to work.
My goal is to get basic routing with two helloworld apps (each different to tell apart), both on port 80, e.g.:
Each of the images works fine if I run them via docker run
in isolation.
Using Powershell from my project dir, /app
, when I run docker-compose up
I get the following:
The Traefik service launches, I can visit the dashboard just fine but the routing table doesn't show my routes. demo1 and demo2 launch just fine, but obviously I can't connect to them because the routing isn't working.
Even though the services all launch successfully - I repeatedly get the following errors:
traefik | ... "Failed to create a client for docker, error: protocol not available" providerName=docker
traefik | ... "Provider connection error protocol not available, retrying ..." providerName=docker
I've included my docker-compose.yml file below, which is the only file in my dir, /app
.
docker-compose.yml:
# app/docker-compose.yml
version: '3.8'
networks:
myweb:
driver: nat
services:
proxy:
image: traefik:v2.3.0-rc4-windowsservercore-1809
container_name: traefik
ports:
- "80:80"
- "8080:8080"
volumes:
- source: '\\.\pipe\docker_engine'
target: '\\.\pipe\docker_engine'
type: npipe
command:
- "--api.insecure=true"
- "--providers.docker"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
networks:
- myweb
labels:
- "traefik.http.routers.dashboard.rule=Host(`dash.localhost`)"
- "traefik.docker.network=app_myweb"
demo1:
image: helloworld:1
container_name: demo1
labels:
- "traefik.enable=true"
- "traefik.docker.network=app_myweb"
- "traefik.port=80"
- "traefik.http.routers.demo1.rule=Host(`demo1.localhost`)"
# Have tried this below, doesn't help.
# volumes:
# - source: '\\.\pipe\docker_engine'
# target: '\\.\pipe\docker_engine'
# type: npipe
networks:
- myweb
depends_on:
- proxy
demo2:
image: helloworld:2
container_name: demo2
labels:
- "traefik.enable=true"
- "traefik.docker.network=app_myweb"
- "traefik.port=80"
- "traefik.http.routers.demo2.rule=Host(`demo2.localhost`)"
networks:
- myweb
depends_on:
- proxy
I saw a suggestion somewhere that I should enable the setting "Expose daemon on tcp://localhost:2375 without TLS"
in Docker Desktop settings, which I have done but doesn't help.
My setup is:
Question #1:
Anybody have any idea what might be causing the problem?
Question #2:
Notice in my file I also have a route set up for the dashboard, to route from dash.localhost to localhost:8080/dashboard, but even that doesn't work. Any idea how to get that working? Do I need to tell it to route from 80->8080 for the dashboard?
According to a ticket on their GitHub you seem to be:
--providers.docker.endpoint=npipe:////./pipe/docker_engine
in Traefik command line\\.\pipe\docker_engine
when Docker is expecting .\pipe\docker_engine
Try making those two changes and see if that helps Traefik connect to your Docker daemon. None of your routes will work until Traefik can talk to Docker to read the labels of your containers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With