2017-05-25 79 views
1

使用docker-compose啓動一個wordpress容器,但在該容器內我想連接到AWS上的RDS mysql實例。我能夠設置WordPress,但無法連接到數據庫。我試着將DB_NAME變量改爲_DATABASE。我也是能夠使用mysql命令行從我的MAC,使其中工程從Docker容器與Wordpress連接到RDS 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 
+0

什麼**主機**你提供嗎? RDS實例地址? –

+0

對於主機,我使用長端點 '.us-west-1.rds.amazonaws.com' – Patrick

回答

2

根據使用WordPress的documentation

環境名稱應該是連接,

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) 
+0

我明白非常感謝! – Patrick

相關問題