docker-Traefik日志在哪里?

前端之家收集整理的这篇文章主要介绍了docker-Traefik日志在哪里? 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

我也尝试指定这些:

[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

我很困惑,我错过了什么吗?还是Traefik应该这么安静?

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

# 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
最佳答案
要在stdout事件中查看日志(如果您运行docker-compose up -d):

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
原文链接:/docker/532496.html

猜你在找的Docker相关文章