mysql - Wordpress 不适用于 docker compose

标签 mysql wordpress docker docker-compose

这是我的 docker-compose.yml

version: '2'

services:

 wordpress:
    image: wordpress:4.6.1-php5.6-apache
    container_name: wordpress
    volumes:
         - ./projects/:/home/docker/
    working_dir: /home/docker/
    ports:
         - "8000:80"
    environment:
        WORDPRESS_DB_PASSWORD: secret
    links:
        - database-mysql

 database-mysql:
   image: mysql:5.7
   container_name: mysqldb
   ports:
     - "3306:3306"
   volumes:
     - ./backups/mysqldb/:/var/lib/mysql/
   environment:
     MYSQL_ROOT_PASSWORD: secret
     MYSQL_DATABASE: wordpress

 phpmyadmin:
   image: phpmyadmin/phpmyadmin:latest
   container_name: phpmyadmin
   ports:
     - "8080:80"
   environment:
     PMA_USER: root
     PMA_PASSWORD: secret
     PMA_HOST: database-mysql
   links:
     - database-mysql

当我运行:docker-compose up时,日志错误显示:

MySQL 连接错误:(2002) php_network_getaddresses:getaddrinfo 失败:名称或服务未知

警告:mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 19

警告:mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 19

2016-11-11 04:14:33,648 INFO success: php-fpm 进入 RUNNING 状态,进程已经停留超过 1 秒 (startsecs)

2016-11-11 04:14:33,648 INFO 成功:nginx 进入 RUNNING 状态,进程已停留 > 超过 1 秒 (startsecs)

我做错了什么?

最佳答案

评论太长了,所以我创建了另一个答案
尝试这个并等待 2 分钟,然后访问 localhost:8000

version: '2'

services:
   db:
     image: mysql:5.7
     volumes:
       - "./.data/db:/var/lib/mysql"
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: wordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     links:
       - db
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_PASSWORD: wordpress

   phpmyadmin:
     image: phpmyadmin/phpmyadmin:latest
     container_name: phpmyadmin
     ports:
       - "8080:80"
     environment:
       PMA_USER: root
       PMA_PASSWORD: secret
       PMA_HOST: database-mysql
     links:
       - db

关于mysql - Wordpress 不适用于 docker compose,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40541078/

相关文章:

mysql - 如何获取mysql中每个组的前300行?

mysql - 选择具有最大 id 值的表行

php - 无法单击我的 wordpress 下拉菜单子(monad)菜单链接

javascript - 如何选择性地将锁定文件添加到 docker 容器?

docker - 在docker-compose.yml中了解容器的主机名

mysql - SQL 比较过去 X 小时列的更改

python - Sqlalchemy 重复条目

wordpress - 在提交联系表单 7 时调用 JavaScript 函数

javascript - 排队脚本时向脚本标记添加其他属性

docker - 无法开始使用Docker