# Docker provider not working, returns error code 404

**URL:** <https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [June 20, 2022, 6:28pm UTC](https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823 "2022-06-20T18:28:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![KjetilKnutsen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/kjetilknutsen/32/5489_2.png) [@KjetilKnutsen](https://community.traefik.io/u/KjetilKnutsen)\
**Post date:** [June 20, 2022, 6:28pm UTC](https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823/1 "2022-06-20T18:28:18Z")

</div>

Have been trying to setup traefik as a reverse proxy with file and docker providers. Currently i have only gotten file provider to work. The docker provider only returns error code 404.

Test container setup:

```auto
docker run -d -p 3000:8080 --name webtest --network proxy --label traefik.enable=true rawmind/web-test

```

Traefik setup

```auto
docker run -d -p 8080:8080 -p 80:80 -p 443:443 --name traefik \
-v /srv/traefik/:/etc/traefik -v /var/run/docker.sock:/var/run/docker.sock \
 --env CLOUDFLARE_API_KEY=api-key \
 --env CLOUDFLARE_EMAIL=admin@domain.com \ traefik:2.7

```

traefik.yml

```auto
global:
  checkNewVersion: true
  sendAnonymousUsage: false

serversTransport:
  insecureSkipVerify: true

log:
  level: DEBUG

accesslog: {}

api:
  insecure: true
  dashboard: true

entryPoints:
  web:
    address: ":80"
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https 

  websecure:
    address: ":443"
    http:
      tls:
        # Generate a wildcard domain certificate
        certResolver: letsencrypt
        domains:
          - main: domain.com
            sans:
              - '*.domain.com'
      middlewares:
        - securityHeaders 

providers:
  providersThrottleDuration: 2s
  file:
    filename: /etc/traefik/fileConfig.yml
    watch: true

  docker:
    watch: true
    endpoint: "unix:///var/run/docker.sock"
    network: proxy
    defaultRule: "Host(`{{ lower (trimPrefix `/` .Name )}}.domain.com`)"
    exposedByDefault: false

# Use letsencrypt to generate ssl serficiates
certificatesResolvers:
  letsencrypt:
    acme:
      email: admin@domain.com
      storage: /etc/traefik/acme.json
      dnsChallenge:
        provider: cloudflare
        # Used to make sure the dns challenge is propagated to the rights dns servers
        resolvers:
          - "1.1.1.1:53"
          - "1.0.0.1:53"

```

fileConfig.yml

```auto
http:
  routers:
    test:
      entrypoints:
        - web
        - websecure
      rule: 'Host(`test.domain.com`)'
      service: test

  ## SERVICES ##
  services:
    test:
      loadBalancer:
        servers:
          - url: http://192.168.0.189:9453/

  ## MIDDLEWARES ##
  middlewares:
    # Only Allow Local networks
    whitelist:
      ipWhiteList:
        sourceRange: 
          - 127.0.0.1/32 # localhost
          - 192.168.0.0/24 # LAN Subnet
  
    # Security headers
    securityHeaders:
      headers:
        customResponseHeaders:
          X-Robots-Tag: "none,noarchive,nosnippet,notranslate,noimageindex"
          server: ""
          X-Forwarded-Proto: "https"
        sslProxyHeaders:
          X-Forwarded-Proto: https
        referrerPolicy: "strict-origin-when-cross-origin"
        hostsProxyHeaders:
          - "X-Forwarded-Host"
        customRequestHeaders:
          X-Forwarded-Proto: "https"
        contentTypeNosniff: true
        browserXssFilter: true
        forceSTSHeader: true
        stsIncludeSubdomains: true
        stsSeconds: 63072000
        stsPreload: true

```

---

<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:** [June 21, 2022, 11:41am UTC](https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823/2 "2022-06-21T11:41:00Z")

</div>

> [@KjetilKnutsen](#):
>
> The docker provider only returns error code 404.

Would you please explain what you mean by saying the Docker provider returns 404?

Once you configure the Docker provider, which you did in your example, the configuration is managed through labels.

I would also recommend starting working with Docker Compose, here is [the example](https://github.com/jakubhajek/traefik-proxy/tree/master/basic-docker-compose) which is good for the beginning.

---

<div class="post-metadata">

**Author:** ![KjetilKnutsen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/kjetilknutsen/32/5489_2.png) [@KjetilKnutsen](https://community.traefik.io/u/KjetilKnutsen)\
**Post date:** [June 21, 2022, 12:08pm UTC](https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823/3 "2022-06-21T12:08:49Z")

</div>

Hi

After I setup a container, I am getting 404 page not found, instead of being sent to correct webpage.  
 ![288429048_1083293885593490_1026711084654577035_n](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/e/ece4cbb96db8f4a8a7bf9fe81b5247b4bc4603f6.png)

The only thing in the access logs I can find is this:

192.168.0.90 - - [21/Jun/2022:12:06:05 +0000] "GET / HTTP/2.0" 404 19 "-" "-" 1184 "-" "-" 0ms

Is there any other labels you would need other than traefik.enable=true?  
As for Docker Compose, the reason I am setting it up this way now, it that the plan is to configure it using Ansible.

---

<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:** [June 21, 2022, 12:45pm UTC](https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823/4 "2022-06-21T12:45:46Z")

</div>

Hello @KjetilKnutsen

Can you please share your docker-compose file? We will try to reproduce it on our test env.

---

<div class="post-metadata">

**Author:** ![KjetilKnutsen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/kjetilknutsen/32/5489_2.png) [@KjetilKnutsen](https://community.traefik.io/u/KjetilKnutsen)\
**Post date:** [June 21, 2022, 12:57pm UTC](https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823/5 "2022-06-21T12:57:19Z")

</div>

I was perphaps not clear, I don't have any docker-compose file, because of wanting to set it up using Ansible later. The containers are only setup with the docker run commands previously given.

---

<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:** [June 21, 2022, 1:05pm UTC](https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823/6 "2022-06-21T13:05:10Z")

</div>

I understand. 404 means that Traefik is not finding the appropriate router to match your request criteria.

It might be caused by a configuration issue so validating your configuration should be crucial.

just wanted to ensure that we are on the same page,  
Do we still investigate the issue with the Docker provider configuration?

---

<div class="post-metadata">

**Author:** ![KjetilKnutsen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/kjetilknutsen/32/5489_2.png) [@KjetilKnutsen](https://community.traefik.io/u/KjetilKnutsen)\
**Post date:** [June 21, 2022, 1:26pm UTC](https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823/7 "2022-06-21T13:26:46Z")

</div>

Yes, it seems to be a configuration error as the test router works with file provider.  
I still want to figure out what the problem is regarding the Docker provider configuration is.

---

<div class="post-metadata">

**Author:** ![KjetilKnutsen](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/kjetilknutsen/32/5489_2.png) [@KjetilKnutsen](https://community.traefik.io/u/KjetilKnutsen)\
**Post date:** [June 22, 2022, 8:02pm UTC](https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823/8 "2022-06-22T20:02:52Z")

</div>

After looking at it again today, I found the issues that were causing it to not work.

First was that the middleware on websecure was not properly set. It was missing @file

```auto
      middlewares:
        - securityHeaders@file

```

Second, was that I had forgot to add the correct docker network to the traefik container. Now it works as it should.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [June 27, 2022, 6:30pm UTC](https://community.traefik.io/t/docker-provider-not-working-returns-error-code-404/14823/9 "2022-06-27T18:30:32Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
