我打算使用Traefik v2.0版,因此首先进行了测试。如果要使用“群存模式”,则始终会获得以下日志条目:
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)
答案 0 :(得分:0)
为我解决的是将包含 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