Skip to content

Using the built in certbot client to fetch proper ssl certificate files from Let's Encrypt

Grey Christoforo edited this page Sep 25, 2017 · 5 revisions

Normally we run the container like this: docker run --name lamp -p 443:443 -d greyltc/lamp and it uses the default self-generated ssl certificate files.

If the docker host machine has proper global DNS bindings and a firewall setup to allow access from the internet to your.domain.tld over port 443, then you can use this method to fetch valid certificate files for your domain from Let's Encrypt.

Just run the container like this:

docker run -e DO_SSL_LETS_ENCRYPT_FETCH=true -e [email protected] -h your.domain.tld --name lamp -p 443:443 -d greyltc/lamp

and it will fetch and install ssl certs into the container at /etc/letscencrypt that shouldn't give you any browser warnings.

After you start the container like this (which fetches your ssl key files from Let's Encrypt) you should probably copy those files out of the container for use later:

docker cp lamp:/etc/letsencrypt ~/letsencryptBackup

Then to use your Let's Encrypt cert files on subsequent runs of the container you would start it like this:

docker run -v ~/letsencryptBackup:/etc/letsencrypt -e USE_EXISTING_LETS_ENCRYPT=true --name lamp -p 443:443 -d greyltc/lamp