# How do I use a TLS certificate within docer-compose

**URL:** <https://community.traefik.io/t/how-do-i-use-a-tls-certificate-within-docer-compose/9333>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [January 16, 2021, 11:29am UTC](https://community.traefik.io/t/how-do-i-use-a-tls-certificate-within-docer-compose/9333 "2021-01-16T11:29:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabi321](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/fabi321/32/3209_2.png) [@fabi321](https://community.traefik.io/u/fabi321)\
**Post date:** [January 16, 2021, 11:29am UTC](https://community.traefik.io/t/how-do-i-use-a-tls-certificate-within-docer-compose/9333/1 "2021-01-16T11:29:51Z")

</div>

Hi, I am completely new to docker and traefik in particular.

I want to run the project [https://github.com/Informatic/workadventure/tree/feature/animated-tiles](https://github.com/Informatic/workadventure/tree/feature/animated-tiles) and wanted to add a TLS certificate to it. I already acquired a certificate from Letsencrypt and since it is only a short term project, I don't need a auto renewal solution.

Thanks in advance for helping.

---

<div class="post-metadata">

**Author:** ![fabi321](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/fabi321/32/3209_2.png) [@fabi321](https://community.traefik.io/u/fabi321)\
**Post date:** [January 16, 2021, 12:21pm UTC](https://community.traefik.io/t/how-do-i-use-a-tls-certificate-within-docer-compose/9333/2 "2021-01-16T12:21:05Z")

</div>

Update: I finally got to a point where I have been able to establish a secure connection using my certificate, however I now get only 404's.

Changes I made:  
additional files

```auto
project dir
 | - traefik.yml
 | - dynamic_conf.yml
 | - certs
      | - cert.pem
      | - privkey.pem

```

dynamic\_conf.yml:

```auto
# Dynamic configuration
tls:
  certificates:
    - certFile: "/etc/traefik/certs/cert.pem"
      keyFile: "/etc/traefik/certs/privkey.pem"

```

traefik.yml:

```auto
## traefik.yml
## Static configuration
entryPoints:
        web:
                address: ":80"
        websecure:
                address: ":443"

# Docker configuration backend
providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
    watch: true
  file:
    filename: /etc/traefik/dynamic_conf.yml
    watch: true

api:
        insecure: true

```

docker-compose.yaml:

```auto
services:
  reverse-proxy:
    image: traefik:v2.0
    command:
      - --api.insecure=true
      - --providers.docker
      - --entryPoints.web.address=:80
      - --entryPoints.websecure.address=:443
    ports:
      - "80:80"
      - "443:443"
      # The Web UI (enabled by --api.insecure=true)
      - "8080:8080"
    depends_on:
      - back
      - front
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik.yml:/etc/traefik/traefik.yml
      - ./dynamic_conf.yml:/etc/traefik/dynamic_conf.yml
      - ./certs:/etc/traefik/certs
…

```

---

<div class="post-metadata">

**Author:** ![fabi321](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/fabi321/32/3209_2.png) [@fabi321](https://community.traefik.io/u/fabi321)\
**Post date:** [January 16, 2021, 2:52pm UTC](https://community.traefik.io/t/how-do-i-use-a-tls-certificate-within-docer-compose/9333/3 "2021-01-16T14:52:10Z")

</div>

Found the issue:  
traefik.yml:

```auto
providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
  file:
    filename: /etc/traefik/dynamic_conf.yml

```

This works like a charm

---

<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:** [January 19, 2021, 2:52pm UTC](https://community.traefik.io/t/how-do-i-use-a-tls-certificate-within-docer-compose/9333/4 "2021-01-19T14:52:16Z")

</div>

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