Using docker-compose to spin up a wordpress container but within that container I want to connect to a RDS mysql instance on AWS. I am able to setup the wordpress but can’t connect to the db. I’ve tried changing the DB_NAME variable to _DATABASE. I also am able to use the mysql command line from my mac to make the connection which works

version: '2'

services:
   wordpress:
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       MYSQL_HOST: "endpoint"
       MYSQL_USER: "user"
       MYSQL_PASSWORD: "pass"
       MYSQL_DB_NAME: "wordpress_docker"
       MYSQL_PORT: 3306
     volumes:
       - ${HOME}:/var/lib/mysql

Read more here: Connecting to RDS Mysql from docker container with WordPress


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: