GoogleCloudPlatform / wordpress-docker

GNU General Public License v2.0
35 stars 47 forks source link

Error establishing database connection #52

Open jonathanhatch opened 5 years ago

jonathanhatch commented 5 years ago

I'm having a very hard time getting this to run in Cloud Run. It's refusing to connect to my database, no matter the combination of environment variables and SQL connections that I try. Any tips?

khajduczenia commented 5 years ago

Hi Jonathan,

Usually you can use a combination of a few environment variables to connect to a database compatible with MySQL:

Could you please share more details about the errors you are getting?

jonathanhatch commented 5 years ago

Here's what I get when I try to simply run a vanilla wordpress image from marketplace.gcr.io/google/wordpress:latest

2019-10-09 07:34:46.585 CDT Cloud Run CreateService wordpress-vanilla jonathan@stpaulmedia.com {@type: type.googleapis.com/google.cloud.audit.AuditLog, authenticationInfo: {…}, authorizationInfo: […], methodName: google.cloud.run.v1.Services.CreateService, request: {…}, requestMetadata: {…}, resourceName: namespaces/saint-paul-media-wordpress/services/wordpress-vanilla, response: {…}, service… 2019-10-09 07:35:05.947 CDT WordPress not found in /var/www/html - copying now... 2019-10-09 07:35:25.340 CDT Complete! WordPress has been successfully copied to /var/www/html 2019-10-09 07:35:27.166 CDT AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message 2019-10-09 07:35:27.167 CDT Container Sandbox Limitation: Unsupported syscall setsockopt(0x4,0x6,0x9,0x3ecfa183155c,0x4,0x1). Please, refer to https://gvisor.dev/c/linux/amd64/setsockopt for more information. 2019-10-09 07:35:27.300 CDT AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message 2019-10-09 07:35:27.300 CDT Container Sandbox Limitation: Unsupported syscall setsockopt(0x4,0x6,0x9,0x3ecfa183155c,0x4,0x0). Please, refer to https://gvisor.dev/c/linux/amd64/setsockopt for more information. 2019-10-09 07:35:27.670 CDT [Wed Oct 09 12:35:27.668739 2019] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.3.9 configured -- resuming normal operations 2019-10-09 07:35:27.671 CDT [Wed Oct 09 12:35:27.670882 2019] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

markxp commented 4 years ago

Seems like you run the wordpress and mysql database in a Cloud Run instance. If you use default settings for environment variables for this image, it will build a new mysql database.

Instead, you should try to link to external database. Build a GCE instance, and links to it or try Cloud SQL.

ganochenkodg commented 2 years ago

Hi Jonathan, Could you please describe step by step how you run wordpress? As far as I can see the container name has already changed since the issue was opened, so I would like to try to reproduce it. And yes, that's a good question - do you use any external MySQL instance (container/gke/cloud sql)?