2
votes

I am new to traefik and wanted to install it on my server. I got a docker server running in swarm mode an have some containers running on the server. Just containers not services.

My fist attempt was to get the traefik docker image and start it. So uses the docker file shown on the let start page and I could see in the Web GUI all my containers.

The problem came when I tried to use a traefik.toml configuration instead of the command line arguments in the docker-compose.yml file.

The following compose file will work and show my container. However, if I use the line currently commented out I will not see an container.

version: '3'

services:
  proxy:
    image: traefik
    command: --api  --docker --docker.domain="portal" --docker.exposedbydefault=false --logLevel=DEBUG
   #  command: --api   --logLevel=DEBUG
    networks:
      - webgateway
    ports:
      - "70:80"
      - "7070:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/grafra1969/traefik/traefik.toml:/etc/traefik/traefik.toml

networks:
  webgateway:
    driver: bridge

According to the logs the configuration file is read and according to my understanding should be similar to the default. What's wrong

Here the settings of the docker section

[docker]
endpoint =  "unix:///var/run/docker.sock"
domain = "portal.net"
ExposedByDefault = true
Watch = true
1
CORRECTION. The command line showing the the container did not include the option --docker.exposedbydefault=false - grafra

1 Answers

2
votes

There were three major problems with my configuration.

  • the file /home/grafra1969/traefik/traefik.toml did not exist. I forgot a folder. Thus the default configuration was used.
  • Using the command line in this way would overwrite the settings for the docker provider with the defaults.
  • When enabling docke.SwarmMode one must make sure that the labels are set on the service and not on the container.

After fixing all this I got it running .