用于Windows的Traefik + Docker:无法为Docker创建客户端,错误:协议不可用&提供者连接错误协议不可用 [英] Traefik + Docker for Windows: Failed to create a client for docker, error: protocol not available & Provider connection error protocol not available

查看:92
本文介绍了用于Windows的Traefik + Docker:无法为Docker创建客户端,错误:协议不可用&提供者连接错误协议不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使基本的Traefik路由设置正常工作。


我的目标是通过两个helloworld应用程序(每个都可以区分)来获得基本路由80,例如:



  • demo1.localhost-> helloworld1

  • demo2.localhost-> helloworld2


如果我单独通过 docker run 运行它们,则每个图像都可以正常工作。 / p>

在运行 docker-compose up / app 使用Powershell $ c>我得到以下信息:


Traefik服务启动,我可以很好地访问仪表板,但是路由表中没有显示我的路线。 demo1和demo2可以很好地启动,但是显然我无法连接到它们,因为路由不起作用。


即使所有服务都成功启动了-我反复得到了出现以下错误

  traefik | ...无法为docker创建客户端,错误:协议不可用 providerName =泊坞窗
traefik | ...提供商连接错误协议不可用,正在重试... providerName = docker

我在下面包括了我的docker-compose.yml文件,这是目录中唯一的文件, / app


docker-compose.yml:

 #app / docker-compose.yml 

版本:'3.8'
网络:
myweb:
驱动程序:nat

服务:
代理:
图像:traefik:v2.3.0-rc4-windowsservercore-1809
container_name:traefik
端口:
- 80:80;
- 8080:8080&;
卷:
-来源:'\\.\pipe\docker_engine'
目标:'\\.\pipe\docker_engine'
类型:npipe
命令:
-"-api.insecure = true"
- --providers.docker
- --providers.docker.exposedbydefault = false
- --entrypoints.web.address =:80
网络:
-myweb
标签:
- traefik.http.routers.dashboard.rule = Host(`dash.localhost`)
- traefik.docker.network = app_myweb

demo1:
图片:helloworld:1
container_name:demo1
标签:
- traefik.enable = true
- traefik.docker.network = app_myweb
- traefik.port = 80;
- traefik.http.routers.demo1.rule = Host(`demo1.localhost`)
#在下面尝试过此操作没有帮助。
#卷:
#-来源:'\\.\pipe\docker_engine'
#目标:'\\.\pipe\docker_engine'
#类型:npipe
网络:
-myweb
取决于:
-代理

demo2:
图片:helloworld:2
container_name:demo2
标签:
- traefik.enable = true
- traefik.docker.network = app_myweb
- traefik.port = 80;
- traefik.http.routers.demo2.rule = Host(`demo2.localhost`)
网络:
-myweb
取决于:
-代理

I在某处看到一个建议,我应该在Docker Desktop设置中启用设置在tcp:// localhost:2375上暴露守护程序而没有TLS ,该设置我已经完成,但是没有做到。


我的设置是:



  • Docker桌面(v19.03.12)对于Windows

  • 使用Windows容器的Docker

  • Windows 10(10.0.18363 Build 18363)


问题#1:


任何人都不知道是什么引起了该问题?


问题2:


在文件中的通知我还为仪表板设置了一条路由,以将dash.localhost路由到localhost:8080 / dashboard,但即使那样也不行。任何想法如何使它工作?我是否需要告诉它从80-> 8080路由到仪表板?

解决方案

根据门票在他们的GitHub上,您似乎是:


  1. 缺少 --providers.docker.endpoint = npipe:///../pipe/docker_engine 在Traefik命令行中

  2. 在Docker预期 .\pipe\docker_engine \\.\pipe\docker_engine c>

尝试进行这两个更改,看看是否可以帮助Traefik连接到您的Docker守护程序。在Traefik可以与Docker交谈以读取您的容器标签之前,您的所有路线都不会起作用。


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?

解决方案

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.

这篇关于用于Windows的Traefik + Docker:无法为Docker创建客户端,错误:协议不可用&提供者连接错误协议不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆