For development purpose, I need to setup an installation of WordPress in a docker container.

I found and follow this tutorial.

Everything is working well, with all the security and optimisation. But the tutorial is based on WordPress 4.5.2. And when everything is setup I cannot upgrade WordPress because of some permission denied. Of course I modified by myself the Dockerfile to get WordPress 4.7 but I will not be able to do the future upgrade.

Also if I need to install a plugin, it fail because it cannot create the folder in my volume. If I mkdir -p the folders everything is working fine.

Here the GitHub with all the files.

So I think everything is linked but I cannot fix it. Any idea ?


The problem, as the error description indicates, is permissions. Based on that tutorial, nginx is running under the www-data user, but WP folders are owned by deployer. If you change the ownership of your $WP_ROOT to www-data:www-data, you will find that you can update your WP. I'm not amazing at security, so there may be a better way, but this one will work to get it updated. In the comment of the tutorial, they made this security change on purpose, so maybe it's not a good idea. Not sure on that level of detail.

On top of this change, this update will not persist if you power down the docker instance. You'll have to update your WP instance each time you restart the container. It might make sense to put the WP files into a volume so that WP can update the files as necessary, and that they persist. This would make sense also since the DB persists, and is part of the upgrade anyway. But these decisions on security are above my pay-grade.

  • 1
    Typically, this will look something like this: chown -R www-data:www-data /var/www/wordpress – Pier-Luc Gendreau Jul 25 '18 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.