Skip to content

Docker: chown WordPress install to web user so wp-admin updates work#49110

Open
DevinWalker wants to merge 1 commit into
trunkfrom
fix/docker-chown-wp-install
Open

Docker: chown WordPress install to web user so wp-admin updates work#49110
DevinWalker wants to merge 1 commit into
trunkfrom
fix/docker-chown-wp-install

Conversation

@DevinWalker
Copy link
Copy Markdown
Contributor

@DevinWalker DevinWalker commented May 22, 2026

Fixes MONOREP-406

Proposed changes

  • Add chown -R "$user:$group" /var/www/html to tools/docker/bin/run.sh just before Apache starts.
  • Provisioning steps in run.sh (wp core download, wp config set, the plugin symlinks loop, etc.) all run as root, but Apache subsequently runs as www-data. Without a chown step, the WordPress install stays owned by root:root and the auto-updater fails with files_not_writable. From the user's side this shows up as:
    • The An automated WordPress update has failed to complete - please attempt the update again now. admin notice.
    • Every plugin / theme / core update from wp-admin failing silently or with a generic error.
    • wp core update succeeding only when run as root via docker exec -u root, never via the normal admin flow.
  • The chown is intentionally unconditional (every container start, not just first-install), so existing environments provisioned before this fix self-heal on the next jetpack docker up — no manual chown required by anyone hitting this today.

Related product discussion/links

  • Surfaced while diagnosing a developer's Docker env where wp-admin had been showing the failed-update notice for weeks and core was pinned at 7.0-beta2-61800 because nothing could overwrite the existing files. Setup workflow referenced: PCYsg-GJ2-p2.
  • Adjacent gap (not addressed here): jetpack docker update-core was announced on +jetpackdevelopment in Feb 2025 but is still undocumented in tools/docker/README.md — separate doc PR could follow.

Does this pull request change what data or activity we track or use?

No — local dev environment script only.

Testing instructions

  1. Start fresh: jetpack docker clean && jetpack docker up -d (or just jetpack docker down && jetpack docker up -d against an existing install that's currently broken).
  2. Once the WordPress container is up, verify ownership inside the container:
    docker exec jetpack_dev-wordpress-1 stat -c '%U:%G' /var/www/html/wp-includes/version.php
    
    Expected: www-data:www-data (previously: root:root).
  3. Visit wp-admin. If a previously-installed environment had been showing "An automated WordPress update has failed to complete - please attempt the update again now", that notice should be gone (or clear after the next update check).
  4. From wp-admin → Dashboard → Updates, click Update to latest version (or run jetpack docker wp core update). It should succeed instead of files_not_writable.
  5. Same for jetpack docker wp plugin update --all and jetpack docker wp theme update --all.
  6. (Optional sanity check) On the host: ls -la tools/docker/wordpress/wp-includes/version.php — Docker Desktop's user namespacing should still present the file as readable from the host.

tools/docker/bin/run.sh runs as root during container init (wp core
download, wp config set, plugin symlinks all execute as root), but
Apache subsequently runs as www-data. Without a chown step, every file
under /var/www/html stays root-owned and the WordPress auto-updater
fails with "files_not_writable" — surfacing the "An automated WordPress
update has failed to complete" admin notice and blocking plugin, theme,
and core updates from wp-admin.

Add an unconditional chown -R "$user:$group" /var/www/html just before
Apache starts. Running on every container start (not just first install)
means existing environments provisioned before this fix self-heal on
the next `jetpack docker up`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@DevinWalker DevinWalker requested a review from a team as a code owner May 22, 2026 21:00
@DevinWalker DevinWalker added the [Status] Needs Review This PR is ready for review. label May 22, 2026
@DevinWalker DevinWalker self-assigned this May 22, 2026
@DevinWalker DevinWalker added the [Status] Needs Review This PR is ready for review. label May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

Copy link
Copy Markdown
Contributor

@tbradsha tbradsha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I suspect this shouldn't cause any issues...

I haven't yet checked out your branch, and everything is root:root on my end, but I'm not able to reproduce the reported issue; updates to plugins/themes work fine for me. Do you have more context on the failing setup?

As for updating core, I can confirm it also worked for me. That said, I recommend instead using jetpack docker update-core (which runs tools/docker/bin/update-core.sh in the env), as otherwise tests that run on Docker risk having mismatched core PHPUnit tests, which have been known to break things.

cc: @anomiex in case I missed some nuance here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docker [Status] Needs Review This PR is ready for review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants