如何告诉 Traefik 在使用 AWS ECS 和 Fargate 时不要尝试连接到 docker.sock
How to tell Traefik not to try to connect to docker.sock when using AWS ECS and Fargate
我正在使用 Fargate 在 AWS ECS 上为 Web 应用程序设置环境。安装程序使用多个容器作为前端和后端,并使用 Traefik(也在一个容器中)在 ALB 后面进行路由。我正在使用 ecs-cli 和 docker-compose 文件进行部署,一切正常。
尽管一切正常,但 traefik 容器不断记录有关无法连接到 docker.sock
的错误
time="2019-09-12T21:54:13Z" level=error msg="Failed to retrieve information of the docker client and server host: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"
time="2019-09-12T21:54:13Z" level=error msg="Provider connection error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, retrying in 3.829225701s"
我非常理解 traefik 将无法在那个环境中连接到 docker.sock,并且当我正确配置 ECS Provider 时,它显然不需要连接到套接字。因此它仍然尝试。
traefik.toml
[entryPoints]
...
[ecs]
clusters = ["cluster-name"]
watch = true
refreshSeconds = 15
exposedByDefault = true
region = "eu-west-1"
domain = "ecs.domain"
[retry]
docker-comopse.yml
version: "3"
services:
proxy:
image: ${custom-image-with-toml-baked-in}
command: --api --docker
ports:
- "80:80"
- "443:443"
- "8080:8080"
labels:
- "traefik.enable=true"
- "traefik.backend=traefik"
- "traefik.frontend.rule=Host:traefik.ecs.domain"
- "traefik.port=8080"
logging:
driver: awslogs
...
...
所以正如我提到的,看起来 Traefik 仍然想连接到 docker.sock,而我找不到告诉 Traefik 只依赖 ECS 的方法。
因此,在查看我的问题时,我仔细检查了 docker-compose 文件中的 command: --api --docker
行,结果发现错误来自 --docker
选项...
此行是早期简单 docker 部署的遗留内容,因此删除此选项对我有用。
docker-compose.yml
version: "3"
services:
proxy:
image: ${custom-image-with-toml-baked-in}
command: --api
ports:
- "80:80"
- "443:443"
- "8080:8080"
labels:
- "traefik.enable=true"
- "traefik.backend=traefik"
- "traefik.frontend.rule=Host:traefik.ecs.domain"
- "traefik.port=8080"
logging:
driver: awslogs
...
...
所以如果有人遇到同样愚蠢的问题,我希望这个独白能有所帮助。
我正在使用 Fargate 在 AWS ECS 上为 Web 应用程序设置环境。安装程序使用多个容器作为前端和后端,并使用 Traefik(也在一个容器中)在 ALB 后面进行路由。我正在使用 ecs-cli 和 docker-compose 文件进行部署,一切正常。
尽管一切正常,但 traefik 容器不断记录有关无法连接到 docker.sock
的错误time="2019-09-12T21:54:13Z" level=error msg="Failed to retrieve information of the docker client and server host: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"
time="2019-09-12T21:54:13Z" level=error msg="Provider connection error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, retrying in 3.829225701s"
我非常理解 traefik 将无法在那个环境中连接到 docker.sock,并且当我正确配置 ECS Provider 时,它显然不需要连接到套接字。因此它仍然尝试。
traefik.toml
[entryPoints]
...
[ecs]
clusters = ["cluster-name"]
watch = true
refreshSeconds = 15
exposedByDefault = true
region = "eu-west-1"
domain = "ecs.domain"
[retry]
docker-comopse.yml
version: "3"
services:
proxy:
image: ${custom-image-with-toml-baked-in}
command: --api --docker
ports:
- "80:80"
- "443:443"
- "8080:8080"
labels:
- "traefik.enable=true"
- "traefik.backend=traefik"
- "traefik.frontend.rule=Host:traefik.ecs.domain"
- "traefik.port=8080"
logging:
driver: awslogs
...
...
所以正如我提到的,看起来 Traefik 仍然想连接到 docker.sock,而我找不到告诉 Traefik 只依赖 ECS 的方法。
因此,在查看我的问题时,我仔细检查了 docker-compose 文件中的 command: --api --docker
行,结果发现错误来自 --docker
选项...
此行是早期简单 docker 部署的遗留内容,因此删除此选项对我有用。
docker-compose.yml
version: "3"
services:
proxy:
image: ${custom-image-with-toml-baked-in}
command: --api
ports:
- "80:80"
- "443:443"
- "8080:8080"
labels:
- "traefik.enable=true"
- "traefik.backend=traefik"
- "traefik.frontend.rule=Host:traefik.ecs.domain"
- "traefik.port=8080"
logging:
driver: awslogs
...
...
所以如果有人遇到同样愚蠢的问题,我希望这个独白能有所帮助。