wordpress docker无法连接到mysql docker

时间:2018-04-22 09:02:02

标签: mysql wordpress docker

不确定我做错了什么,但我的wordpress docker只是没有连接到mysql docker。有人可以帮我吗?

version: '2'
services: 
db:  
  image: mysql:8.0
  container_name: eve_db
  volumes:
    - ./database/data:/var/lib/mysql
    - ./database/initdb.d:/docker-entrypoint-initdb.d
  restart: always
  environment:
    MYSQL_ROOT_PASSWORD: skdjd           # any random string will do
    MYSQL_DATABASE: djdjd                # the name of your mysql database
    MYSQL_USER: djdjd                    # the name of the database user
    MYSQL_PASSWORD: djdjd                # the password of the mysql user
wordpress:
  depends_on:
    - db
  image: wordpress:php7.2                   # we're using the image with php7.1
  container_name: eve_de
  ports:
    - "8080:80"
  restart: always
  links:
    - db:mysql
  volumes:
    - ./src/wp:/var/www/html

我也定义了

  

define('DB_HOST','db:3306');

在wp-config.php文件中。但它没有用。

1 个答案:

答案 0 :(得分:0)

主站点有mysql v5.6.38。在docker-compose.yml中更改相同内容解决了这个问题。