Traefik的原木在哪里?

时间:2019-02-19 22:39:04

标签: docker traefik

您碰巧知道Traefik日志的位置吗?我阅读了Traefik上的文档,并说它将输出到stdout,但是当我使用docker-compose up -d启动docker容器时,在尝试域名并拉出多个链接的docker容器后,stdout中没有任何显示。 / p>

我也尝试指定这些:

[traefikLog]
  filePath = "./traefik.log" #<--Tried this but It doesn't work, file empty and permissions set to 777

[accessLog]
  filePath = "./access.log" #<--Tried this but doesn't work, file empty and permissions set to 777

我很困惑,我想念什么吗?还是特拉菲克应该这么安静?

当我运行它时,这就是我所看到的,此后什么也没有。

# docker-compose up
Creating traefik ... done
Attaching to traefik

附上我的配置。谢谢。

traefik / traefik.toml:

logLevel = "DEBUG"
defaultEntryPoints = ["http","https"]

[api]
  address = ":8080"

[traefikLog]
  filePath = "./traefik.log" #<--Tried this but It doesn't work

[accessLog]
  filePath = "./access.log" #<--Tried this but doesn't work

[entryPoints]
  [entryPoints.http]
    #redirect ALL http traffic to https 443
    address = ":80"
    [entryPoints.http.redirect]
      entryPoint = "https"
  [entryPoints.https]
    address = ":443"
    [entryPoints.https.tls]

#Let's encrypt setup
[acme]
  email = "email@email.com"
  storage = "acme.json"
  entryPoint = "https"
  acmeLogging = true
  #When new host is created, request certificate.
  onHostRule = true
  onDemand = false
  [acme.httpChallenge]
    entryPoint = "http"

#Watch Docker, when new containers are created with label create mapping.
[docker]
  endpoint = "unix:///var/run/docker.sock"
  domain = "exampledomain.net"
  watch = true
  exposedbydefault = false

docker-compose.yml:

version: '3'
services:
  traefik:
    hostname: traefik
    domainname: exampledomain.net
    image: traefik:alpine
    command: --api --docker
    container_name: traefik
    networks:
      - nginx-proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "./traefik/traefik.toml:/traefik.toml"
      - "./traefik/acme.json:/acme.json"
    labels:
      - "traefik.enable=true"
      - "traefik.port=8080"
      - "traefik.frontend.rule=Host:monitor.exampledomain.net"
      - "traefik.docker.network=nginx-proxy"

networks:
  nginx-proxy:
    external:
      name: nginx-proxy

3 个答案:

答案 0 :(得分:2)

如果运行docker-compose up -d,则要查看stdout事件中的日志:

docker-compose log -f

https://docs.docker.com/compose/reference/logs/

仅供参考,路径./traefik.log位于Traefik容器内。

[traefikLog]
  filePath = "./traefik.log" 

关于您的文件(没有[traefikLog]部分),我看到了日志。


但是,您的配置存在一些问题:

version: '3'
services:
  traefik:
    hostname: traefik
    domainname: exampledomain.net
    image: traefik:v1.7.9-alpine
    # command: --api --docker # <-- don't define the same configuration with CLI and TOML https://docs.traefik.io/basics/#static-traefik-configuration
    container_name: traefik
    networks:
      - nginx-proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "./traefik/traefik.toml:/traefik.toml"
      - "./traefik/acme.json:/acme.json"
    labels:
      - "traefik.enable=true"
      - "traefik.port=8080"
      - "traefik.frontend.rule=Host:monitor.exampledomain.net"
      - "traefik.docker.network=nginx-proxy"

networks:
  nginx-proxy:
    external:
      name: nginx-proxy
logLevel = "DEBUG"
defaultEntryPoints = ["http","https"]

[api]
  # address = ":8080" <- this options doesn't exist. https://docs.traefik.io/v1.7/configuration/api/

# [traefikLog] # <-- remove because not needed
#   filePath = "./traefik.log"

# [accessLog] # <-- remove because not needed
#   filePath = "./access.log"

[entryPoints]
  [entryPoints.http]
    address = ":80"
    [entryPoints.http.redirect]
      entryPoint = "https"
  [entryPoints.https]
    address = ":443"
    [entryPoints.https.tls]

# Let's encrypt setup
[acme]
  email = "email@email.com"
  storage = "acme.json"
  entryPoint = "https"
  acmeLogging = true
  onHostRule = true
  onDemand = false
  [acme.httpChallenge]
    entryPoint = "http"

[docker]
  endpoint = "unix:///var/run/docker.sock"
  domain = "exampledomain.net"
  # watch = true # <---- useful only for swarm
  exposedbydefault = false

答案 1 :(得分:0)

我正在共享一个docker-compose文件。这将为日志创建一个卷,访问日志和服务日志都可以从该卷中获取

"networks":
  "network":
    "external":
      "name": "appliance"
"services":
  "container":
    "container_name": "traefik"
    "image": "traefik:1.7.4"
    "networks":
    - "network"
    "ports":
    - "80:80"
    - "443:443"
    - "8099:8099"
    "restart": "always"
    "volumes":
    - "/var/run/docker.sock:/var/run/docker.sock"
    - "{pwd}/traefik.toml:/traefik.toml"
    - "{pwd}/acme.json:/acme.json"
    - "logs:/var/log/traefik"
"version": "3.4"
"volumes":
  "logs":
    "name": "traefik_logs"

如下所示在traefik.toml中添加日志位置
[accessLog]
filePath =“ /var/log/traefik/access.log”

答案 2 :(得分:0)

只需将 [accessLog] 添加到您的 traefik.toml 文件中即可。