acme-companion: Don't always create a new certificate on startup

Hi there,

I got the Issue in a project of mine, that the companion creates a new certificate on every docker-compose up even though valid certificates are already in place from a startup before. Is there a flag or a way to tell the companion, to first look if in the certs folder are already valid certificates for the VIRTUAL_HOST?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 24 (10 by maintainers)

Most upvoted comments

In 2 ways:

  1. The logs running through always stated something about certificate creation and i saw in the nginx logs, that the .well-known was reached out to
  2. After a couple of docker-compose down and docker-compose up on a system, the companion stated, that we reached the maximum of certificate requests for that domain in that week

I should add: If I start everything, except the lets-encrypt service in the setup, I have the valid certificate from the startup before still in place and the SSL-encryption works like a charm; without a new certificate.

@nekym so based on your existing config:

version: '3'

services:
[...]
  letsencrypt-companion:
    image: jrcs/letsencrypt-nginx-proxy-companion
    restart: always
    volumes:
      - certs:/etc/nginx/certs
      - vhost.d:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - acme:/etc/acme.sh # Mount the acme volume to the companion
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - proxy-tier
    depends_on:
      - proxy

volumes:
  certs:
  vhost.d:
  html:
  acme: # Add the acme volume to your compose file
[...]

Everything else should be the same.

@nekym sorry I completely forgot to get back to you, yes you got that right, I’ll post an exemple config updated from yours tomorrow.

For development purposes i regulary deleted my images, so it is the latest version available thorugh the docker repository.

If you also delete your volumes, there will be no cached certificate, so it will request a new one.