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

**URL:** <https://community.traefik.io/t/enable-and-configure-file-provider-within-a-docker-compose-defined-traefik-instance/9732>\
**Category:** Traefik v2\
**Tags:** file, docker\
**Created:** [February 17, 2021, 11:35am UTC](https://community.traefik.io/t/enable-and-configure-file-provider-within-a-docker-compose-defined-traefik-instance/9732 "2021-02-17T11:35:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![coolnodje](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@coolnodje](https://community.traefik.io/u/coolnodje)\
**Post date:** [February 17, 2021, 11:35am UTC](https://community.traefik.io/t/enable-and-configure-file-provider-within-a-docker-compose-defined-traefik-instance/9732/1 "2021-02-17T11:35:09Z")

</div>

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:

> Blockquote  
> labels:  
> - "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=[http://192.168.0.28](http://192.168.0.28)"

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?

---

<div class="post-metadata">

**Author:** ![coolnodje](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@coolnodje](https://community.traefik.io/u/coolnodje)\
**Post date:** [February 17, 2021, 2:19pm UTC](https://community.traefik.io/t/enable-and-configure-file-provider-within-a-docker-compose-defined-traefik-instance/9732/2 "2021-02-17T14:19:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jakubhajek](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jakubhajek/32/3389_2.png) [@jakubhajek](https://community.traefik.io/u/jakubhajek)\
**Post date:** [February 19, 2021, 2:38pm UTC](https://community.traefik.io/t/enable-and-configure-file-provider-within-a-docker-compose-defined-traefik-instance/9732/3 "2021-02-19T14:38:48Z")

</div>

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)`

[https://doc.traefik.io/traefik/providers/file/](https://doc.traefik.io/traefik/providers/file/)

Hope that helps to solve your issue.

Thanks, Jakub

---

<div class="post-metadata">

**Author:** ![coolnodje](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@coolnodje](https://community.traefik.io/u/coolnodje)\
**Post date:** [February 19, 2021, 3:00pm UTC](https://community.traefik.io/t/enable-and-configure-file-provider-within-a-docker-compose-defined-traefik-instance/9732/4 "2021-02-19T15:00:08Z")

</div>

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](https://doc.traefik.io/traefik/providers/file/) 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)

---

<div class="post-metadata">

**Author:** ![jakubhajek](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jakubhajek/32/3389_2.png) [@jakubhajek](https://community.traefik.io/u/jakubhajek)\
**Post date:** [February 19, 2021, 3:23pm UTC](https://community.traefik.io/t/enable-and-configure-file-provider-within-a-docker-compose-defined-traefik-instance/9732/5 "2021-02-19T15:23:00Z")

</div>

Correct, the File provider can read configuration from the directory(see that [example](https://github.com/jakubhajek/traefik-swarm-mastery/blob/0d6bb1be42773c5d640b97b34bc2fbae70b54e02/traefik.yml#L27)) 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](https://github.com/jakubhajek/traefik-swarm-mastery/blob/master/conf.d/routers.toml) should be helpful.

Regards,
