Docker: “certbot certonly” gets ignored

I try to create a lets encrypt cert within my nginx docker container that gets successfully built within my gitlab ci pipeline:

FROM nginx:stable-alpine
FROM certbot/certbot:latest

ADD nginx.conf /etc/nginx/nginx.conf
ADD nginx-ssl.conf /etc/nginx/nginx-ssl.conf

COPY angular/dist/angular /usr/share/nginx/

RUN certbot certonly --agree-tos --email --webroot -w /usr/share/nginx/ -d -d || echo "ERROR: certbot certonly failed!"
RUN ls /etc/letsencrypt && (cat var/log/letsencrypt/letsencrypt.log || echo "ERROR: letsencrypt.log not found!") && rm /etc/nginx/nginx.conf && mv /etc/nginx/nginx-ssl.conf /etc/nginx/nginx.conf

EXPOSE 80 443

Unfortunately, this fails within my kubernetes cluster pod deployment with the following error:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Certbot doesn't know how to automatically configure the web server on this system. However, it can still get a certificate for you. Please run "certbot certonly" to do so. You'll nee
d to manually configure your web server to use the resulting certificate.

Has anyone an idea on why the command “RUN certbot certonly (…)” gets ignored in regard to the docker context?
The nginx serving of my angular app without ssl on port 80 works perfectly…

Thanks a lot :slight_smile: