Using certbot when Nginx is running in a docker container

Hi! What's the best way to set up certbot when Nginx (and everything else) is running inside docker container on a docker swarm configuration? Would I need to run certbot in a container on the same network? I tried setting it up manually since the guide mentions:

Most users should use the instructions at certbot.eff.org. You should only use Docker if you are sure you know what you are doing and have a good reason to do so.

But on doing so and running sudo certbot --nginx I just get this error:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
The nginx plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError("Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.")

1 Like

Running nginx in a Docker container probably is a good reason to also run certbot in a Docker container. However, note that experience with Docker on this Community less compared to when certbot is ran without Docker.

1 Like

The documentation you have linked shows you how to run Certbot through Docker.

What you're looking for is a way to secure your dockerized nginx server, which is a bit more tricky.

Sorry in advance for saying this, but I suggest searching around for "docker swarm + nginx + lets encrypt". There are a lot of different approaches to achieving this; usually involving docker-compose or sometimes even more elaborate setups.

Consider also some "container native" solutions like Traefik which can reduce the pain of making SSL happen in clustered environments, like with Docker Swarm.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.