Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

423
Views
Wordpress not connecting to database with nginx, letsencrypt, and docker compose

I have a VPS setup with debian 10 and looking to add multiple wqordpress sites using docker compose. I am using nginx and letsencrypt in separate containers...and that part seems to be working. I get the SSL and can ping the site, WP wont connect to the database though and I have a feeling I am missing something simple...I'm a newb with docker and compose

here is my docker-compose.yml file

version: "3"

services:
   db_domain:
     image: mysql:5.7
     volumes:
        - db_data:/var/lib/mysql
     restart: always
     environment:
        MYSQL_ROOT_PASSWORD: Password1234
        MYSQL_DATABASE: domain-db
        MYSQL_USER: domainUser
        MYSQL_PASSWORD: otherPassword1234
     container_name: domain-db

   wordpress:
     depends_on:
        - db_domain
     image: wordpress:latest
     expose:
        - 80
     restart: always
     environment:
        VIRTUAL_HOST: domain.com
        LETSENCRYPT_HOST: domain.com
        LETSENCRYPT_EMAIL: admin@domain.com
        WORDPRESS_DB_HOST: db_domain:3306
        WORDPRESS_DB_USER: domainUser
        WORDPRESS_DB_PASSWORD: otherPassword1234
     container_name: domain-wp
volumes:
  db_data:

networks:
  default:
    external:
      name: nginx-proxy
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You have a couple of issues: The environment variables for the Mysql service are not setup properly and the Wordpress service is missing the WORDPRESS_DB_NAME: domain-db environment variable. Here is a configuration that comes up without DB errors:

version: "3"

services:
   db_domain:
     image: mysql:5.7
     volumes:
        - db_data:/var/lib/mysql
     restart: always
     environment:
        - MYSQL_ROOT_PASSWORD=Password1234
        - MYSQL_DATABASE=domain-db
        - MYSQL_USER=domainUser
        - MYSQL_PASSWORD=otherPassword1234
     container_name: domain-db
     ports:
       - "3306:3306"
   wordpress:
     depends_on:
        - db_domain
     image: wordpress:latest
     expose:
        - 80
     restart: always
     environment:
        VIRTUAL_HOST: domain.com
        LETSENCRYPT_HOST: domain.com
        LETSENCRYPT_EMAIL: admin@domain.com
        WORDPRESS_DB_HOST: db_domain:3306
        WORDPRESS_DB_USER: domainUser
        WORDPRESS_DB_PASSWORD: otherPassword1234
        WORDPRESS_DB_NAME: domain-db
     container_name: domain-wp
volumes:
  db_data:
over 4 years ago · Santiago Trujillo Report

0

You have to add this WORDPRESS_DB_NAME: domain-db.

And the WORDPRESS_DB_PASSWORD must to be equal to MYSQL_PASSWORD.

Anyway, RTFM -> https://hub.docker.com/_/wordpress/

Best regards.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!