这是我的docker-compose文件
version: '3'
networks:
traefik-net:
driver: bridge
services:
# The reverse proxy service (Træfik)
reverse-proxy:
image: traefik # The official Traefik docker image
ports:
- "80:80" # The HTTP port
- "8082:8082" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik.toml:/etc/traefik/traefik.toml
labels:
- "traefik.docker.network=traefik-net"
networks:
- traefik-net
auth:
image: auth
labels:
- "traefik.enable=true"
- "traefik.backend=auth"
- "traefik.frontend.rule=Host:auth.localhost"
- "traefik.docker.network=traefik-net"
networks:
- traefik-net
clients:
image: clients
labels:
- "traefik.enable=true"
- "traefik.backend=clients"
- "traefik.frontend.rule=Host:clients.localhost"
- "traefik.docker.network=traefik-net"
networks:
- traefik-net
这是我的 traefik.toml 文件
defaultEntryPoints = ["http"]
[api]
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "traefik.localhost"
watch = true
[entryPoints]
[entryPoints.traefik]
address = ":8082"
[entryPoints.http]
address = ":80"
我想做的是从 auth容器向 clients容器发出请求 在 auth容器中,我执行此命令
wget -qO- --header =“主机:clients.localhost” http://localhost/
我得到此输出
wget:无法连接到远程主机(127.0.0.1):连接被拒绝
在容器外部,命令员可以正常工作。 如何使用traefik从一个容器向另一个容器发出请求
感谢您的帮助:)