Enable and configure file provider within a docker-compose defined Traefik instance

I've been successfully using Traefik with a docker-compose.yml configuration.
I was using the Docker provider only though.

Now I need to allow access to an existing non Docker service through the same Traefik instance.

I have one single config point, the docker-compose.yml file, and would like to keep it so.

I tried to add the following labels to the docker-compose.yml file:

- "traefik.http.routers.nextcloud.rule=Host(nextcloud.example.org) || Host(nextcloud.host.example.org)"
- "traefik.http.routers.nextcloud.entrypoints=websecure"
- "traefik.http.routers.nextcloud.service=nextcloud-svc"
- "traefik.http.services.nextcloud-svc.loadBalancer.servers.url="

This doesn't seem to be picked up by Traefik though.
But if I add --providers.file=true to the command section, then I get an error file cannot be a standalone element (type *file.Provider)

Makes sense, but I wish I could just tell the file provider that I'm providing config through the labels.

Is there a way to achieve this?

It actually seems to be taking into account file provider config labels passed by docker-composed.yml.
Though I still need to activate the file provider with - --providers.file.directory=/ passed in the command: section otherwise Iget the error Cannot start the provider *file.Provider: error using file configuration provider, neither filename or directory defined

Simultaneously I get another error "field not found, node: servers" providerName=docker container=traefik-dockerhost-xxx which actually probably is the reason why the docker provider doesn't seem to b working anymore.

hello @coolnodje

Please have a look at the documentation on how to configure File provider because seems that it is incorrect syntax. That's why you are getting file cannot be a standalone element (type *file.Provider)


Hope that helps to solve your issue.

Thanks, Jakub

What I'm trying to achieve is to provide a file provider configuration to Traefik from a docker-compose.yml file.

It doesn't seem to be possible from the documentation File - Traefik tough, which only make reference to providing documentation form a file or a directory.

Just wanted to be sure, as I seemed to be able to get it working... almost (not along a docker provider config)

Correct, the File provider can read configuration from the directory(see that example) that is being used to keep files with dynamic configuration, it is useful when you would like to split config files.

You can also point directly to the one file. Both use cases are described in the documentation we both mentioned.

However, if you would like to have Traefik that works with Docker services as well as with standalone services running somewhere in your infrastructure I think that configuration file should be helpful.