If I understand this correctly what you are required to do is to have a web server being hosted at a specific domain and then execute the certbot command with specific arguments.
I have created a directory in my VPS named live
under that I created the following,
docker-compose.yml
web/Dockerfile
web/index.html
config/nginx/conf.d/default.conf
letsencrypt/
Inside docker-compose.yml
version: "3.8"
services:
web:
build:
context: "./web"
dockerfile: "Dockerfile"
ports:
- "80:80"
container_name: "web"
volumes:
- "./config/nginx/conf.d:/etc/nginx/conf.d"
certbot:
image: "certbot/certbot"
volumes:
- "./letsencrypt:/etc/letsencrypt"
command: certonly
Inside default.conf
server {
listen 80;
server_name mydomain.com www.mydomain.com;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /.well-known/acme-challenge/ {
root /usr/share/nginx/html;
allow all;
try_files $uri =404;
}
}
I first try to build docker compose build web
, then docker compose up -d web
, checking on my domain I see the website hosting my simple index.html
just fine.
Running the docker compose run certbot
will execute the setup script, at some point it requests me to put a --webroot
path which when I enter /usr/share/nginx/html
doesn't seem to work, which I don't understand.