使用WordPress从Docker容器连接到RDS Mysql

使用docker-compose启动一个wordpress容器,但在该容器内,我想连接到AWS上的RDS mysql实例。 我能够设置WordPress,但无法连接到数据库。 我试着将DB_NAMEvariables改为_DATABASE。 我也能够使用从我的Mac的MySQL命令行,使连接工作

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 

根据WordPress的文档

环境名称应该是,

 WORDPRESS_DB_HOST=... (defaults to the IP and port of the linked mysql container) WORDPRESS_DB_USER=... (defaults to "root") WORDPRESS_DB_PASSWORD=... (defaults to the value of the MYSQL_ROOT_PASSWORD environment variable from the linked mysql container) WORDPRESS_DB_NAME=... (defaults to "wordpress") WORDPRESS_TABLE_PREFIX=... (defaults to "", only set this when you need to override the default table prefix in wp-config.php)