nginx_docker-swag/root/etc/cont-init.d
Patrick Bellasi 0bd3b646c6 Fix network resolution errors at startup
Starting this container can fail at certbot initialization with this
error (reported at the end of /var/log/letsencrypt/letsencrypt.log):

   HTTPSConnectionPool(host='acme-v02.api.letsencrypt.org', port=443):
   Max retries exceeded with url: /directory "[Errno -3] Try again"

which sounds like a possible DNS resolution problem.

However, by logging into the container after the error above, a simple:

   wget https://acme-v02.api.letsencrypt.org/directory

usually works. It works also the exact same certbot command
logged in /var/log/letsencrypt/letsencrypt.log.

This has been verified happening while installing the contained on a
QNAP NAS with a bridged network setup.

Turns out that by adding a small delay right before running network
access operations (e.g. running certbot) fixes all the issues.
Likely a small sleep is good enough for the host/container to properly
setup the network stack.

Since this happens only at container startup, let's add a one-off 5s
sleep right before issuing the first certbot command.

Signed-off-by: Patrick Bellasi <patrick.bellasi@matbug.net>
2021-02-07 17:31:04 +01:00
..
50-config Fix network resolution errors at startup 2021-02-07 17:31:04 +01:00
60-renew initial release 2020-08-03 11:00:14 -04:00
70-templates remove unnecessary eab retrieval 2020-12-20 16:55:11 -05:00