Error “cannot load certificate”, when deploing wordpress and certbot with docker-compose

Hi
please help me with resolve problem with my VPS and SSL Certificate. My Docker Compose:

version: '3.3'

services:

    #MySQL service - database for website.
    db:
            image: mysql:8.0
            container_name: db
            restart: unless-stopped
            env_file: .env
            environment:
                    - MYSQL_DATABASE=wordpress
            volumes:
                    - dbdata:/var/lib/mysql
            command: '--default-authentication-plugin=mysql_native_password'
            networks:
                    - website-net

    #Wordpress application
    wordpress:
            depends_on:
                    - db
            image: wordpress:5.1.1-fpm-alpine
            container_name: wordpress
            restart: unless-stopped
            env_file: .env
            environment:
                    - WORDPRESS_DB_HOST=db:3306
                    - WORDPRESS_DB_USER=$MYSQL_USER
                    - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
                    - WORDPRESS_DB_NAME=wordpress
            volumes:
                    - website:/var/www/html
            networks:
                    - website-net

    #Nginx webserver
    webserver:
            depends_on:
                    - wordpress
            image: nginx:1.15.12-alpine
            container_name: webserver
            restart: unless-stopped
            ports:
                    - '80:80'
                      #                       - '443:443'
            volumes:
                    - website:/var/www/html
                    - ./nginx-conf:/etc/nginx/conf.d
                    - certbot-etc:/etc/letsencrypt
            networks:
                    - website-net

    #Certbot for SSL certificate
    certbot:
           depends_on:
                   - webserver
           image: certbot/certbot
           container_name: certbot
           volumes:
                   - certbot-etc:/etc/letsencrypt
                   - website:/var/www/html
           command: certonly --webroot --webroot-path=/var/www/html --email gawronski.tomaszz@gmail.com --agree-tos --no-eff-email --staging -d gawronskitomasz.pl -d www.gawronskitomasz.pl

volumes:
dbdata:
website:
certbot-etc:

networks:
website-net:
driver: bridge

And problem:

webserver | nginx: [emerg] cannot load certificate "/etc/letsencrypt/live/gawronskitomasz.pl/fullchain.pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/letsencrypt/live/gawronskitomasz.pl/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)

My webserver all time is restarting and I can't download a new certificate.
Please resolve me this problem.

Tom

Did somehow get the contents of the volume certbot-etc get erased?

2 Likes

First, you will need to remove the HTTPS section that is using that file which no longer exists.
Then you can obtain the cert.
Then you can add that section back in.

1 Like

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