docker的wordpress容器不能连接到数据库容器

我一直在使用dockerbuild立WordPress的应用程序一些日子。 我有一些工作,但现在我不知道为什么我可以连接数据库容器和WordPress的容器。

我已经将失败的configuration简化为最简单的可能。

现在我有以下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" 

并在前端build立数据库连接出错

我在这里粘贴了完整的日志,以防有人想要看看: http : //pastebin.com/Z9U2iMsH

我有我的环境之前运行,我相信,如果不是这个特殊的例子,我已经能够运行容器,并连接到数据库与我今天尝试(没有运气)的一些例子,所以我想有什么问题与我的环境,但我不知道如何debugging它。

我已经删除了所有的容器,所有的图像,重新载入图像,重build容器。 甚至用新创build的docker-compose.yml文件对enpty文件夹进行testing。

实际上,在阅读日志的时候,似乎wordpress进程已经耗尽了它的尝试,我甚至重新启动了wordpress容器, 数据库容器已经启动,结果是一样的。

以防万一它是相关的我使用docker快速启动terminal在Mac上本地运行所有这些,如下所述:

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上引入的一个bug

我在这里做了一个

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

我会保持这个问题,以防万一,但似乎很清楚,这是一个错误

这是wordpress容器4.4.1版本的一个bug。

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

谢谢大家!