skip to Main Content

I am working with Docker and its containers and I want to add more than 1 WordPress site in its containers with Nginx, PHP and Letscrypt. I have 1 container with the database, 2 containers with wordpress and phpfpm7.4. Another container with nginx and 2 more containers with certbot to generate the ssl certificates I already have the docker-compose.yml file but it seems that the problem I have is with a second certbot container that is not generating the certificate. Here I leave the docker file and the error it throws me.

version: '3'

services:
  dbgb:
    image: mysql:8.0.30
    container_name: dbgb
    restart: unless-stopped
    env_file: .env
    environment:
      - MYSQL_ROOT_PASSWORD=Wordpress123
      - MYSQL_DATABASE=greatbytedb
      - MYSQL_USER=wordpressuser
      - MYSQL_PASSWORD=Wordpress321
    volumes:
      - dbdata:/var/lib/mysql
    command: '--default-authentication-plugin=mysql_native_password'
    networks:
      - app-network

  wordpressgb:
    depends_on:
      - dbgb
    image: wordpress:6.0.2-php7.4-fpm-alpine
    container_name: wordpressgb
    restart: unless-stopped
    env_file: .env
    environment:
      - WORDPRESS_DB_HOST=dbgb:3306
      - WORDPRESS_DB_USER=$MYSQL_USER
      - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
      - WORDPRESS_DB_NAME=greatbytedb
    volumes:
      - greatbyte:/var/www/html
    networks:
      - app-network


  wordpresshc:
    depends_on:
      - dbgb
    image: wordpress:6.0.2-php7.4-fpm-alpine
    container_name: wordpresshc
    restart: unless-stopped
    env_file: .env
    environment:
      - WORDPRESS_DB_HOST=dbgb:3306
      - WORDPRESS_DB_USER=$MYSQL_USER
      - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
      - WORDPRESS_DB_NAME=greatbytedb
    volumes:
      - hablamedecuba:/var/www/html/hablamedecuba
    networks:
      - app-network

  webservergb:
    depends_on:
      - wordpressgb
      - wordpresshc

    image: nginx:1.23.1-alpine
    container_name: webservergb
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - greatbyte:/var/www/html
      - hablamedecuba:/var/www/html/hablamedecuba
      - ./nginx-conf:/etc/nginx/conf.d
      - certbot-etc:/etc/letsencrypt
    networks:
      - app-network
  
  
  certbotgb:
    depends_on:
      - webservergb
    image: certbot/certbot
    container_name: certbotgb
    volumes:
      - certbot-etc:/etc/letsencrypt
      - greatbyte:/var/www/html
    command: certonly --webroot --webroot-path=/var/www/html --email [email protected] --agree-tos --no-eff-email --force-renewal -d great-byte.com -d www.great-byte.com

  certbothc:
    depends_on:
      - webservergb
    image: certbot/certbot
    container_name: certbothc
    volumes:
      - certbot-etc:/etc/letsencrypt
      - hablamedecuba:/var/www/html/hablamedecuba
    command: certonly --webroot --webroot-path=/var/www/html/hablamedecuba --email [email protected] --agree-tos --no-eff-email --force-renewal -d hablamedecuba.com -d www.hablamedecuba.com

volumes:
  certbot-etc:
  greatbyte:
  hablamedecuba:
  dbdata:

networks:
  app-network:
    driver: bridge

enter image description here

2

Answers


  1. The challenge cannot be execute because hablamedecuba.com isn’t reachable for lets’ encrypt to download the temporary challenge file.

    *   Trying 142.93.119.120:80...
    * connect to 142.93.119.120 port 80 failed: Connection refused
    * Failed to connect to hablamedecuba.com port 80 after 168 ms: Connection refused
    * Closing connection 0
    curl: (7) Failed to connect to hablamedecuba.com port 80 after 168 ms: Connection refused```
    
    Either try to use a different challenge or make it available on port 80 temporarily.
    
    Login or Signup to reply.
  2. You try after add below code.

    certbot:
        depends_on:
            - webserver
        image: certbot/certbot
        container_name: certbot
        networks:
            - backend
        volumes:
            - 'certbot-etc:/etc/letsencrypt'
            - 'certbot-var:/var/lib/letsencrypt'
            - '/tmp/acme-challenge:/tmp/acme-challenge'                        
        restart: unless-stopped        
        environment:
            TZ: '${LOCAL_TIMEZONE}'
        entrypoint: /bin/sh -c "certbot certonly --webroot --webroot-path /tmp/acme-challenge --rsa-key-size 4096 --non-interactive --agree-tos --no-eff-email --force-renewal --email ${LETSENCRYPT_EMAIL} -d ${DOMAIN_NAME} -d www.${DOMAIN_NAME}; 
            trap exit TERM; while :; do certbot renew --dry-run; sleep 12h & wait $${!}; done;"
    

    or

    This link enter link description here is ready to install full stack docker compose wordpress. I suggest you try, tried and it is work.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search