在play-with-docker.com

时间:2019-07-03 09:29:24

标签: docker traefik

在尝试在自己的专用服务器上运行 traefik 之前,我尝试在play-with-docker.com上进行测试。

但是,我无法获得一个包含2个容器的简单示例,请参见下面的docker-compose.yml文件。容器都以up开头,它们的日志中没有任何错误。我可以在端口80上看到带有子路径/traefik traefik仪表板。但是我看不到端口80上带有子路径/dozzle dozzle

我的配置有什么问题? 还是 traefik play-with-docker.com上根本无法正常工作?

如果我取消注释ports部分,则可以在端口8083上看到问题-但这不是我想要的,那么我将绕过traefik ...

感谢所有提示...

---
version: '3.5'

networks:
  proxy:
    name: proxy
    driver: bridge
  web:
    name: web
    driver: bridge

services:
  traefik:
    image: traefik
    container_name: traefik
    restart: always
    command:
      - "--logLevel=INFO"
      - "--api"
      - "--defaultentrypoints=http"
      - "--docker"
      - "--docker.watch"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - proxy
      - web
    ports:
      - "80:80"
    labels:
    - "traefik.enable=true"
    - "traefik.backend=traefik"
    - "traefik.frontend.rule=PathPrefixStrip:/traefik"
    - "traefik.port=8080"
    - "traefik.docker.network=proxy"

  dozzle:
    image: amir20/dozzle
    container_name: dozzle
    restart: always
    depends_on:
      - traefik
    command:
      - "--level=DEBUG"
      - "--base=/dozzle"
      - "--addr=:8083"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    # ports:
    #   - 8083:8083
    networks:
      - proxy
    labels:
    - "traefik.enable=true"
    - "traefik.backend=dozzle"
    - "traefik.frontend.rule=PathPrefixStrip:/dozzle"
    - "traefik.port=8083"
    - "traefik.docker.network=proxy"

编辑13.07.2019-其他信息

我使用Docker Toolbox在本地计算机上尝试了compose文件的简化版本。还是一样的问题。如果我在http://192.168.99.100/dozzle上,我会得到一个空白的页面,而在http://192.168.99.100上,我会得到一个404的错误。

这是简化版:

---
version: '3.5'

services:

  traefik:
    image: traefik
    container_name: traefik
    restart: always
    command:
      - "--docker"
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  dozzle:
    image: amir20/dozzle
    container_name: dozzle
    restart: always
    depends_on:
      - traefik
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - "traefik.enable=true"
      - "traefik.frontend.rule=PathPrefixStrip:/dozzle"
      - "traefik.port=8080"

如果我要切换到浏览器中的源代码视图,则进入http://192.168.99.100/dozzle的空白页面包含一个HTML页面。但是,仅显示空白页面。我认为HTML代码中的相对链接无法解析,因此无法加载CSS,JS等。

4 个答案:

答案 0 :(得分:0)

尝试将其添加到您的traefik服务的端口部分:

ports:
  - '80:80'
  - '443:443'
  - '8080:8080'

然后为您Dozzle尝试一下:

- traefik.port=80

这可能是个人的事情,但我始终将“网络”网络用作外部网络。

答案 1 :(得分:0)

如果我松开了dozzle命令行选项“ -base = / doozle ”,则应该通过路径

到达后端
  

:8083 / dozzle

但是在您的前端规则中,您从初始请求中删除/剥离了“ / doozle”:

"traefik.frontend.rule=PathPrefixStrip:/dozzle"

因此,您应该只使用 PathPrefix

答案 2 :(得分:0)

我找到了现在可以使用的解决方案。感谢所有提示。也许我同时更改了许多选项;-(

此撰写文件有效:

---
version: '3.5'

services:

  traefik:
    image: traefik
    container_name: traefik
    restart: always
    command:
      - "--docker"
      - "--logLevel=INFO"
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  dozzle:
    image: amir20/dozzle
    container_name: dozzle
    restart: always
    depends_on:
      - traefik
    command:
      - "--base=/dozzle"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - "traefik.enable=true"
      - "traefik.frontend.rule=PathPrefix:/dozzle"
      - "traefik.port=8080"

现在我在http://192.168.99.100/dozzle上看到了Dozzle,例如转发到http://192.168.99.100/dozzle/container/9b03de0e20a8

答案 3 :(得分:0)

作为参考,Dozzle 将使用 addr 参数侦听不同的端口;所以在 traefik 2.0 中这种组合有效

  # Dozzle - Real-time Docker Log Viewer
  dozzle:
    hostname: 'dozzle'
    container_name: dozzle
    image: amir20/dozzle:latest
    environment:
      - 'PGID=${ID}'
      - 'PUID=${ID}'
      - 'TZ=${TZ}'
      - 'UMASK=022'
      - DOZZLE_LEVEL=info
      - DOZZLE_TAILSIZE=300
    # - DOZZLE_FILTER="status=running"
    restart: unless-stopped
    networks:
      - proxy
    command:
      - "--addr=:9999"
    security_opt:
      - 'no-new-privileges:true'
    ports:
      - '127.0.0.1:9999:9999'
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock:ro'  # Use Docker Socket Proxy instead for improved security
    labels:
      - "traefik.enable=true"
      - 'traefik.docker.network=proxy'
      - 'dockupdater.enable=true'
      ## HTTP Routers
      - 'traefik.http.routers.dozzle-rtr.entrypoints=https'
      - 'traefik.http.routers.dozzle-rtr.rule=Host(`dozzle.${DOMAIN}`)'
      - 'traefik.http.routers.dozzle-rtr.tls=true'
      - 'traefik.http.routers.dozzle-rtr.tls.certresolver=dns-cloudflare'
      ## Middlewares
      - 'traefik.http.routers.dozzle-rtr.middlewares=chain-authelia@file'
      ## HTTP Services
      - 'traefik.http.routers.dozzle-rtr.service=dozzle-svc'
      - 'traefik.http.services.dozzle-svc.loadbalancer.server.port=9999'