I am trying to create a Docker container with apt-mirror, Cerbot for Letsencrypt, and Nginx.

There is an image for nginx/certbot, but it's based on Alpine Linux. For apt-mirror I require a debian-based distribution.

I've tried the official EFF tutorial but get the following error:

invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of force-reload.
Failed to open connection to "system" message bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
Setting up packagekit-tools (1.1.5-2+deb9u1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for ca-certificates (20161130+nmu1+deb9u1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
Processing triggers for dbus (1.10.26-0+deb9u1) ...
Processing triggers for systemd (232-25+deb9u11) ...
Error: 'universe' invalid

My dockerfile:

FROM nginx:stable

RUN apt-get update &&\
    apt-get install -y cron software-properties-common &&\
    add-apt-repository universe &&\
    add-apt-repository ppa:certbot/certbot &&\
    apt-get update &&\
    apt-get install certbot python-certbot-nginx

RUN certbot --nginx &&\
    certbot renew --dry-run

CMD [ "sh", "-c", "nginx" ]
  • I don't think it is a good idea to run certbot in the Dockerfile. The RUN directives in the Dockerfile are executed when the image is created, not when a container is started. If you use a generated image for months you will not get any renewed certificates. It would make more sense to move this into a startup script or even out of the container, for the case that a container runs for more than 3 months. – Gerald Schneider Jun 7 at 13:22
  • I plan to trigger renew via container's cron. Neverthereless here is a very popular container but it's Alpine: hub.docker.com/r/linuxserver/letsencrypt it looks very much "on steroids" but I can't run apt-mirror there I assume. – J. Doe Jun 7 at 13:40
  • Get the working container for letsencrypt, and mount the needed shared volumes from you nginx container. – Zeitounator Jun 11 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.