Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Traefik + Docker for Windows: Failed to create a client for docker, error: protocol not available & Provider connection error protocol not available

Tags:

docker

traefik

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.:

  • demo1.localhost -> helloworld1
  • demo2.localhost -> helloworld2

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:

  • Docker Desktop (v19.03.12) for Windows
  • Docker using Windows Containers
  • Windows 10 (10.0.18363 Build 18363)

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?

like image 860
stuzor Avatar asked Nov 06 '22 05:11

stuzor


1 Answers

According to a ticket on their GitHub you seem to be:

  1. Missing --providers.docker.endpoint=npipe:////./pipe/docker_engine in Traefik command line
  2. Sharing \\.\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.

like image 174
kichik Avatar answered Nov 14 '22 21:11

kichik