How to fix "WordPress Connection Information" on WP that is running in a docker container ?

March 17, 2017 2.3k views
WordPress Docker CentOS

Hello,

I have a WP website is running in a docker container. I am using all offical images (WP, MariaDB).

I have a problem that is I can not upgrade WP, plugins, install new plugins, delete unsed plugins,... from WP admin dashboard

In non-docker enviroment, I met the same problem and fix it by the command "chown apache:apache /path/to/wp". Now on docker I don't know how to resolve it.

Give me some guide, please.

Thanks in advance.

Best regards,

2 Answers
JoeGC March 22, 2017
Accepted Answer

If you're using Docker-Compose, you'll want to run bash or sh into your Wordpress service container:

sudo docker-compose exec WORDPRESS_SERVICE_NAME sh

When done correctly you should find yourself within the Wordpress /var/www/html directory inside the container. You want to make sure you're in the same directory that the wp-config.php file is located.

Open wp-config.php with your text editor of choice and add the following line to the end of the file:

define('FS_METHOD','direct');

Save or write the changes to the file and navigate back to the Wordpress update page, it should now be able to update without needing the FTP connection information.

Thanks to http://www.hongkiat.com/blog/update-wordpress-without-ftp/ for the tip.

After you've finished updating you can always go back and comment out the addition if you're worried you'll have users on the server who might upload malicious code. You can read up on the security concerns for this here.

Thank you, it works on normal lamp mod_php over Centos 7 also.

Have another answer? Share your knowledge.