Skip to content

Updating the SSL certificate for a Web server running in a Docker container

To update the SSL certificate, you need to:

  1. Enter the nginx-certbot container:

    docker exec -it nginx-certbot /bin/bash
    

    Result: You gain access to the command line inside the container.

  2. Create a directory for ACME validation:

    mkdir -p /var/www/html/.well-known/acme-challenge
    

    Result: The necessary directory structure for domain verification is created.

  3. Set the correct permissions:

    chown -R www-data:www-data /var/www/html/.well-known
    
    chmod -R 755 /var/www/html/.well-known
    

    Result: The correct permissions are set for the web server.

  4. Renew the certificate:

    certbot renew --webroot -w /var/www/html
    

    Result: The certificate renewal process is initiated. A success message will be displayed upon completion.

  5. Exit the container:

    exit
    

    Result: You exit the container's command line and return to the main system.

  6. Restart the container:

    docker restart nginx-certbot
    

    Result: The container is restarted, applying the new certificate to the web server.