Docker-compose with let’s encrypt: TLS Challenge

    For the TLS challenge you will need:

    • A publicly accessible host allowing connections on port with docker & docker-compose installed.
    • A DNS record with the domain you want to expose pointing to this host.
    • Create a docker-compose.yml on your remote server with the following content:
    • Replace [[email protected]](https://doc.traefik.io/cdn-cgi/l/email-protection) by your own email within the certificatesresolvers.myresolver.acme.email command line argument of the traefik service.
      1. #- "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
    • Run docker-compose up -d within the folder where you created the previous file.

    Note

    What changed between the basic example:

    • We replace the entry point by one for the https traffic:
    • We configure the Https let’s encrypt challenge:
    1. # Enable a tls challenge named "myresolver"
    2. - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
    • We add a volume to store our certificates:
    • We configure the whoami service to tell Traefik to use the certificate resolver named myresolver we just configured:
    1. labels:
    2. # Uses the Host rule to define which certificate to issue