Skip to content

Set WORDPRESS_DB_HOST to external DB #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Set WORDPRESS_DB_HOST to external DB #56

wants to merge 1 commit into from

Conversation

pkallberg
Copy link

A previous commit by @tianon seems to have broken the ability to connect to an external DB. This addresses that problem, but may or may not play well with using a linked DB.

@md5
Copy link
Contributor

md5 commented Feb 7, 2015

After #55, you can now set WORDPRESS_DB_HOST directly to set the external db host instead of the MYSQL_PORT_3306_TCP hack that was just a side effect of supporting a linked mysql container.

@pkallberg
Copy link
Author

Thanks @md5. Doesn't the WORDPRESS_DB_HOST='mysql' portion of your commit (line 5) interfere with that environment variable? Seems the container needs WORDPRESS_DB_HOST set to eg. 111.111.111.111:3306 to be able to connect.

I'm currently seeing this error without the change I made:

Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 10
Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 10
MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known

EDIT: Perhaps if I don't set the MYSQL_PORT_3306_TCP env var, it won't get overridden?

@pkallberg
Copy link
Author

Yep that is indeed the case. Sorry about the confusion!

@pkallberg pkallberg closed this Feb 7, 2015
@md5
Copy link
Contributor

md5 commented Feb 7, 2015

Yes, the WORDPRESS_DB_HOST line you refer to will set the host to "mysql", but only if MYSQL_PORT_3306_TCP is set (indicating that a --link some-mysql:mysql is present).

@md5
Copy link
Contributor

md5 commented Feb 7, 2015

It might be worth checking in the entrypoint if both WORDPRESS_DB_HOST and MYSQL_PORT_3306_TCP are set and either warning or erroring out in that case.

@md5
Copy link
Contributor

md5 commented Feb 7, 2015

I opened a PR at #57 to use WORDPRESS_DB_HOST and issue a warning in the case that both WORDPRESS_DB_HOST and MYSQL_PORT_3306_TCP are set.

@mrjackdavis
Copy link

I actually just ran into this issue. The error mentioned by @pkallberg was very misleading.

@pkallberg
Copy link
Author

Sorry about that @mrjackdavis, hope you got it sorted! Thanks @md5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants