docker wordpress容器无法连接到数据库容器

时间:2016-01-12 14:54:53

标签: mysql wordpress docker mariadb

我已经使用docker来构建wordpress应用程序已有几天了。我有一些工作,但现在我不知道为什么我可以连接数据库容器和wordpress容器。

我已将失败的配置简化为最简单的配置。

现在我有以下docker-compose.yml文件:

wordpress:
  image: wordpress
  links:
    - db:mysql
  ports:
    - 8080:80

db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: example

这是这个官方例子的精确副本:

https://hub.docker.com/_/wordpress/

(向下滚动到" ...通过docker-compose")。

如果我使用此文件编写,我会得到以下相关日志条目:

Creating miqueladell_db_1
Creating miqueladell_wordpress_1
Attaching to miqueladell_db_1, miqueladell_wordpress_1
db_1        | Initializing database

......很多初始化......

wordpress_1 | Warning: mysqli::mysqli(): (HY000/2002): Connection refused in - on line 10

......这种情况持续了一段时间,db_1说它正在初始化,而wordpress_1表示它可以连接 然后......

db_1        | MySQL init process done. Ready for start up.

......更多数据库消息......

db_1        | 2016-01-12 14:34:46 139698309449664 [Note] mysqld: ready for connections.
wordpress_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.5. Set the 'ServerName' directive globally to suppress this message
wordpress_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.5. Set the 'ServerName' directive globally to suppress this message
wordpress_1 | [Tue Jan 12 14:34:47.180996 2016] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/5.6.17 configured -- resuming normal operations
wordpress_1 | [Tue Jan 12 14:34:47.181253 2016] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

...如果我浏览到wordpress端点,那就是那个妈妈......

wordpress_1 | 192.168.99.1 - - [12/Jan/2016:14:34:47 +0000] "GET / HTTP/1.1" 500 586 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"

前端的建立数据库连接错误

我已将完整的日志粘贴到此处,以防有人想要查看:http://pastebin.com/Z9U2iMsH

我之前运行过我的环境,我确信如果不是这个特定的例子,我已经能够运行容器并使用我尝试过的一些示例(没有运气)连接到数据库所以我猜测我的环境有问题,但我不知道如何调试它。

我已删除所有容器,所有图像,重新加载图像并重建de容器。甚至在一个带有新创建的docker-compose.yml文件的enpty文件夹上进行测试。

事实上,当阅读日志时,似乎wordpress进程耗尽其尝试我甚至重新启动wordpress容器数据库容器已经启动且结果相同。

以防万一它是相关的我在mac上使用docker quickstart终端本地运行所有这些,如下所示:

https://docs.docker.com/mac/step_one/

docker -v 说:

Docker version 1.9.1, build a34a1d5

编辑:刚尝试使用:

image: wordpress:4.4

而不是"没有标签"最新下载(撰写本文时为4.4.1)并且有效。所以这似乎是4.4.1上引入的错误

我在这里开了一个

https://github.com/docker-library/wordpress/issues/120

我会保持问题公开以防万一,但似乎很明显是一个错误

1 个答案:

答案 0 :(得分:3)

这是wordpress容器版本4.4.1的错误。

我在这里https://github.com/docker-library/wordpress/issues/120已经解决了问题,现在已经解决了。

全部谢谢!