简体   繁体   中英

Traefik container fails with file rules

I am trying to run a simple Traefik container with a yml configuration to make some tests, but I cannot start it.

docker-compose.yml

version: '3.7'

services:
  proxy:
    image: traefik:v2.0.1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${PWD}/traefik.yml:/etc/traefik/traefik.yml
    command:
      - --providers.docker=true
      - --providers.file.filename=/etc/traefik/traefik.yml
      - --entryPoints.web.address=:7000
      # - --providers.docker.swarmMode=true
      - --log.level=DEBUG
    ports:
      - "9999:8080"
      - "7000:80"

traefik.yml

http:
  routers:
    to-reg:
      entryPoints:
        - web
      rule: Path(`/reg`)
      service: srv-reg

  services:
    srv-reg:
      loadBalancer:
        servers:
          - url: http://192.168.226.141:9900

When I run docker-compose up , I get:

proxy_1  | 2019/10/02 11:29:33 command traefik error: invalid node traefik: no child

I am pretty sure I am doing a silly error, but I cannot understand which from the log.

I finally found my error (and as expected is a silly one): I had not understood the distinction between static and dynamic configuration and I was mounting the dynamic one where traefik expects the static. This cause that strange error.

Once I renamed traefik.yml in dyn-traefik.yml I have been able to mount in /etc/traefik and start the proxy with expected routing configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM