【问题标题】:Provider connection error Cannot connect to the Docker daemon提供程序连接错误无法连接到 Docker 守护程序
【发布时间】:2019-09-22 21:41:27
【问题描述】:

我打算使用 Traefik v2.0 版本,因此首先测试了一些东西。如果我想使用 Swarm 模式,我总是会得到以下日志条目:

time="2019-09-22T21:30:28Z" level=error msg="Provider connection error Cannot connect to the Docker daemon at tcp://127.0.0.1:2377. Is the docker daemon running?, retrying in 507.606314ms" providerName=docker
time="2019-09-23T05:58:39Z" level=error msg="Failed to retrieve information of the docker client and server host: Cannot connect to the Docker daemon at tcp://127.0.0.1:2377. Is the docker daemon running?" providerName=docker

我的 docker.yml 文件:

version: '3.5'

services:
  reverse-proxy:
    image: traefik:v2.0
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik:/etc/traefik

我的 traefik.toml 文件:

[providers]
    [providers.docker]
        endpoint = "tcp://127.0.0.1:2377"
        swarmMode = true
        watch = true

[api]
    insecure = true

[log]
    level = "DEBUG"

端口:

$ sudo lsof -i -P -n | grep LISTEND

dockerd    501   root   24u  IPv6  858243      0t0  TCP *:2377 (LISTEN)
dockerd    501   root   30u  IPv6  858280      0t0  TCP *:7946 (LISTEN)
dockerd    501   root   40u  IPv6 1024853      0t0  TCP *:80 (LISTEN)
dockerd    501   root   58u  IPv6 1024882      0t0  TCP *:8080 (LISTEN)
sshd       510   root    3u  IPv4   13105      0t0  TCP *:22 (LISTEN)
sshd       510   root    4u  IPv6   13115      0t0  TCP *:22 (LISTEN)
glusterd   514   root   10u  IPv4   13127      0t0  TCP *:24007 (LISTEN)

【问题讨论】:

  • 不要混合traefik.toml、环境变量和命令行,不支持。 endpoint = "tcp://127.0.0.1:2377" 仅在您的 docker swarm 管理器侦听 127.0.0.1 上的端口 2377 时才有效。我建议你把这条线注释掉。最后,whoami 不听8080
  • 我已经删除了命令行变量,没有正面结果。
  • 我建议您可能想要进行所有更改。
  • 问题不在于 whoami,我无法访问 traefik 仪表板。
  • 我听到了。您需要对我在第一条评论中建议的所有内容进行更改才能取得进展。

标签: docker traefik


【解决方案1】:

为我解决的问题是将包含 docker unix 套接字和 TLS 证书的 docker 卷移动到相应的 docker-compose 部分。

我的目标是拥有一个代理来管理 Bitbucket 应用程序。在下面查看我的示例

services:

proxy-traefik:
    image: traefik:v2.4
    container_name: proxy_traefik
    restart: always
    deploy:
      replicas: 1
      restart_policy:
        condition: any
    ports:
      - "8080:8080" # Traefik dashboard
      - "80:80"
      - "443:443"
    command:
      ## CLI commands to configure Traefik and tell it how to work!
      ## API Settings - https://docs.traefik.io/operations/api/, endpoints - https://docs.traefik.io/operations/api/#endpoints
      - --api.insecure=true # <== Enabling insecure api, NOT RECOMMENDED FOR PRODUCTION
      - --api.dashboard=true # <== Enabling the dashboard to view services, middlewares, routers, etc
      - --api.debug=true # <== Enabling additional endpoints for debugging and profiling
      - --log.level=DEBUG
      ## Provider Settings - https://docs.traefik.io/providers/docker/#provider-configuration
      - --providers.docker=true # <== Enabling docker as the provider for traefik
      - --providers.docker.exposedbydefault=false # only expose enabled containers
      ## Entrypoints Settings - https://docs.traefik.io/routing/entrypoints/#configuration
      - --entrypoints.app.address=:80 # <== Defining an entrypoint for port :80 named web
      - --entrypoints.app-secured.address=:443 # <== Defining an entrypoint for https on port :443 named app-secured
    labels:
      ## Labels define the behavior and rules of the traefik proxy for this container ####
      - "traefik.enable=true" # <== Enable traefik on itself to view dashboard and assign subdomain to view it
      - "traefik.http.routers.api.rule=Host(`monitor.${BITBUCKET_DOMAIN}`)" # <== Setting the domain for the dashboard
      - "traefik.http.routers.api.service=api@internal" # <== Enabling the api to be a service to access
      - "com.navico.rnd.app=bitbucket_proxy"
      - "com.navico.rnd.env=prod"
      - "com.navico.rnd.name_file=traefik"
    volumes:
      # - /home/ubuntu/traefik.toml:/etc/traefik/traefik.yml # not using toml anymore
      - ./tls_certs:/navicotls # <== Volume for certs (TLS)
      - /var/run/docker.sock:/var/run/docker.sock

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-12
    • 1970-01-01
    • 2021-02-26
    • 1970-01-01
    • 2017-05-15
    • 2018-11-07
    • 2018-09-30
    • 1970-01-01
    相关资源
    最近更新 更多