Closed AxelDenhaut closed 2 years ago
I'm not able to reproduce any issues with the container running. The wp-config-docker.php
is a specific template for WORDPRESS_
env vars
$ env | grep WORDPRESS
WORDPRESS_DB_HOST=db
WORDPRESS_DB_PASSWORD=examplepass
WORDPRESS_DB_USER=exampleuser
WORDPRESS_DB_NAME=exampledb
$ env | grep WORDPRESS > .env
$ docker run -d --name mysql --network=test -e MYSQL_DATABASE=db -e MYSQL_USER=exampleuser -e MYSQL_PASSWORD=examplepass -e MYSQL_RANDOM_ROOT_PASSWORD=1 mysql
205661b1016cc0ae8dd9b38a5c6bee9bb7823ef560c994250b2c5300c147b30c
$ docker run -d --env-file=.env --name wpbuild --network=test wordpress
13186f8198f3082c986eefb64052a73dc1716c18de18eb7a5e33f4cb3e024165
$ docker logs wpbuild
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html
No 'wp-config.php' found in /var/www/html, but 'WORDPRESS_...' variables supplied; copying 'wp-config-docker.php' (WORDPRESS_DB_HOST WORDPRESS_DB_NAME WORDPRESS_DB_PASSWORD WORDPRESS_DB_USER)
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
[Tue May 25 17:31:34.089308 2021] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.19 configured -- resuming normal operations
[Tue May 25 17:31:34.089377 2021] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
$ docker exec -it wpbuild bash
root@13186f8198f3:/var/www/html# env | grep WORDPRESS
WORDPRESS_DB_HOST=db
WORDPRESS_DB_PASSWORD=examplepass
WORDPRESS_DB_USER=exampleuser
WORDPRESS_DB_NAME=exampledb
It sounds like you've perhaps been using our image to pre-populate wp-config.php
to be used elsewhere without running the image? I think WP-CLI is probably better suited to your goals.
Since upgrading to 5.7.2-php7.4-alpine, this issue has started to occur for us as well. We were using environment variables in 5.6.x-php7.3-alpine just fine before.
Checking the file history here: https://github.com/docker-library/wordpress/commits/master/latest/php7.4/fpm-alpine/wp-config-docker.php
I see that 5.7.x introduced a new way to handle this. We were supplying a wp-config.php with our build, so when the docker runs it's ignoring the new wp-config-docker.php file. Therefore, our env vars are being ignored.
@AxelDenhaut Be aware that this also breaks your existing KEY and SALT vars that were stored in wp-config.php. You'll also have to feed them in to env vars as well.
To maintainers: In my opinion, this is a significant breaking change that has caused a fairly massive amount of rework/struggling with our Wordpress implementation. We've lost a week to trying to unravel this, and our only trigger to understand the changes you've made here was this issue.
I have the same issue now at the moment ! How can I fix it? I used .ENV variables for Host, DB, USER etc.? I have scripts for a full automated WordPress Installation which fails now because .ENV variables ignored !
I encounter the same problem, wp-config.php
doesn't read environment variables and causes Error establishing a database connection
error.
Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name does not r
esolve in /var/www/html/wp-includes/wp-db.php on line 1653 Warning: mysqli_real_connect():
(HY000/2002): php_network_getaddresses: getaddrinfo failed: Name does not resolve in
/var/www/html/wp-includes/wp-db.php on line 1653
php_network_getaddresses: getaddrinfo failed: Name does not resolve
This issue is not only from Gitlab, also when i try to do it manually on Kubernetes. It started - like Vermyndax said - since 5.7. At the copy of "wp-config-docker.php" file to wp-config.php, the env does not get set for me at all.
I run Wordpress in Kubernetes. I have /var/www/html/wp-content as a persistant storage and i have set the enviorments: WORDPRESS_DB_HOST and WORDPRESS_DB_PASSWORD.
When i run the containers with the image "wordpress:5", it just copies the wp-config-docker.php to wp-config.php. That's it. From inside the container, i can do an env command and it does show the correct things that should be set in the wp-config.php file. root@**container*-969f79968-4ktr5:/var/www/html# env | grep WORDPRESS WORDPRESS_DB_HOST=-mysql WORDPRESS_DB_PASSWORD=*SecretPassWord***
My wp-config.php file, after depoyment: // Database settings - You can get this info from your web host // /* The name of the database for WordPress / define( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpress') );
/* Database username / define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') );
/* Database password / define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') );
When i use wordpress:5.6, i am getting the fields filled in.
Any idea how we can fix this?
@jonneolie, I'm guessing it is because you aren't setting WORDPRESS_DB_USER
.
Also, the env values are no longer embedded in the wp-config file, instead that getenv_docker
function is reading it from the environment when the php runs.
Hey everyone ! I'm working on a website that use Wordpress - Docker, and since I'm trying to update the website, I've encountered an issue with the wp-config file. I can't get environnement variables to work. It was working like a charm before updating to wordpress 5.7, and the new method to manage wp-config (with the getenvdocker function) I'm not using any secrets to manage my database credentials, I'm just passing variables through a gitlab-ci file (I get credentials variable from GitLab) In the log, I'm getting this : `No 'wp-config.php' found in /var/www/html, but 'WORDPRESS...' variables supplied; copying 'wp-config-docker.php'`
Is there anything to do with these variables ? I'm passing the variables in the job that way :
And of course I set up every variables to make that work (that was working until the update) :
As I said, it was working before the update. Am I missing something ? There's no need to add
_FILE
after my variables name since I'm not using secrets right ?I'm a little lost there, I'm not used to docker configuration, but I can't see what's happening here.