Letsencrypt cert auto getting and renewal script based on letsencrypt base image.
/.well-known/acme-challenge directory properly.
Example, for nginx add location for your server: location '/.well-known/acme-challenge' {
default_type "text/plain";
root /tmp/letsencrypt;
}
-v /data/letsencrypt:/etc/letsencrypt
-v /data/letsencrypt-www:/tmp/letsencrypt
docker run \
--name some-letsencrypt \
-v /data/letsencrypt:/etc/letsencrypt \
-v /data/letsencrypt-www:/tmp/letsencrypt \
-e 'DOMAINS=example.com www.example.com' \
-e '[email protected]' \
-e 'WEBROOT_PATH=/tmp/letsencrypt' \
kvaps/letsencrypt-webroot
Configure your app to use certificates in the following path:
/etc/letsencrypt/live/example.com/privkey.pem/etc/letsencrypt/live/example.com/cert.pem/etc/letsencrypt/live/example.com/chain.pem/etc/letsencrypt/live/example.com/fullchain.pemNOTE: You should connect /etc/letsencrypt directory fully, because if you connect just /etc/letsencrypt/live, then symlinks to your certificates inside it will not work!
You can also assign hook for your container, it will be launched after letsencrypt receive a new certificate.
-v /var/run/docker.sock:/var/run/docker.sock--link to your container. Example: --link some-nginxLE_RENEW_HOOK environment variable to your container:Example hooks:
-e 'LE_RENEW_HOOK=docker kill -s HUP @CONTAINER_NAME@'-e 'LE_RENEW_HOOK=docker restart @CONTAINER_NAME@'For more detailed example, see the docker-compose configuration
This is example of letsencrypt-webroot with nginx configuration:
docker-compose.yml
nginx:
restart: always
image: nginx
hostname: example.com
volumes:
- /etc/localtime:/etc/localtime:ro
- ./nginx:/etc/nginx:ro
- ./letsencrypt/conf:/etc/letsencrypt
- ./letsencrypt/html:/tmp/letsencrypt
ports:
- 80:80
- 443:443
environment:
- LE_RENEW_HOOK=docker kill -s HUP @CONTAINER_NAME@
letsencrypt:
restart: always
image: kvaps/letsencrypt-webroot
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock
- ./letsencrypt/conf:/etc/letsencrypt
- ./letsencrypt/html:/tmp/letsencrypt
links:
- nginx
environment:
- DOMAINS=example.com www.example.com
- [email protected]
- WEBROOT_PATH=/tmp/letsencrypt
- EXP_LIMIT=30
- CHECK_FREQ=30
You also can run it with once mode, just add once in your docker command.
With this option a container will exited right after certificates update.
example.com www.example.com.[email protected]./tmp/letsencrypt.root:root.644.30.30.Content type
Image
Digest
sha256:3e5cf01a3…
Size
85.4 MB
Last updated
2 months ago
docker pull neatous/letsencrypt