docker wordpress container can’t connect to database container

I’ve been using docker to build wordpress apps for some days. I got some working but now I don’t know why I can get to connect the database container and the wordpress container.

I’ve reduced the failing condiguration to the simplest possible.

Read More

Right now I have the following docker-compose.yml file:

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

db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: example

which is an exact copy of this official example:

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

(scroll down to “… via docker-compose”).

If I do composer up with this file I got the following relevant log entries:

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

…lots of initialization…

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

…this goes on for a while, db_1 says it’s initializing and wordpress_1 says it can connect
and then…

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

…some more database messages…

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'

…at that momment if I browse to the wordpress endpoint I got…

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"

And an Error establishing a database connection on the front end.

I’ve pasted the full log here in case someone want’s to take a look: http://pastebin.com/Z9U2iMsH

I’ve got my environment running before and I am sure that if not this particular example I have been able to run the containers and connect to the database with some of the examples I tried (without luck) today so I guess there is something wrong with my environment but I don’t know how to debug it.

I’ve removed all containers, all images, re-donwloaded the images and rebuilt de containers. Even tested everyithing on a enpty folder with a newly created docker-compose.yml file.

In fact as reading the logs it seemed that maybe the wordpress process was exhausting its tries I have even restarted the wordpress container while the database container was already up and the result is the same.

Just in case it’s relevant I’m running all of this locally on a mac using the docker quickstart terminal as descrived here:

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

and docker -v says:

Docker version 1.9.1, build a34a1d5

EDIT: Just tried using:

image: wordpress:4.4

instead of “no tag” which downloads latest (4.4.1 at the time of writing) and it works. So it seems that is a bug introduced on 4.4.1

I’ve oppened one here

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

I’ll keep the question open just in case but it seems quite clear that is a bug

Related posts

1 comment

Comments are closed.