Moritz Reitz
← Back to blog
Web DevelopmentIT Systems

Fix Docker WordPress Permission Errors on Bind-Mounted wp-content

Running WordPress in Docker with a bind-mounted wp-content directory? Here's why the container can't write files and the exact fix for WSL2.

2 September 2026 · Moritz Reitz

I run WordPress locally in Docker with ./wp-content bind-mounted from the host. After getting the container up, I tried to install a plugin and got a permission error. Uploads failed. Nothing in the admin that touched the filesystem worked. This post covers the root cause and the exact fix.

Why Docker WordPress Gets Permission Denied on wp-content

The official WordPress Docker image runs the web server process as www-data, which has UID 33 inside the container. When you bind-mount ./wp-content from the host, Docker doesn't change the ownership — the container sees files owned by whoever owns them on the host. On a typical Linux or WSL2 setup, that's your personal user account (UID 1000).

The result: the container process running as UID 33 tries to write to a directory owned by UID 1000. Linux says no.

This is especially common on WSL2 because the host www-data group may not exist at all, or may have a different GID than 33, so group-based workarounds that might work on native Linux don't apply.

The Fix: Two Parts

You need to fix both the container side (what UID runs the process) and the host side (what permissions the directory has). Fixing only one won't work.

1. Run the Container as the Host User

In docker-compose.yml, add a user directive to the WordPress service:

wordpress:
  image: wordpress:latest
  user: "1000:33"

1000 is the UID of your host user — the same user that owns ./wp-content. 33 is the GID of www-data inside the container, which the web server expects for group-level access. This combination means the container process is the owner of the bind-mounted files (so it can write them) while still belonging to the www-data group (so web server internals that check group membership keep working).

The Docker Compose user directive accepts uid:gid or a username — use the numeric form here since the username moritz doesn't exist inside the container.

2. Set Correct Ownership and Permissions on the Host

On the host, the wp-content directory needs to be owned by your user and group-owned by www-data, with group write access:

mkdir -p wp-content
sudo chown moritz:www-data wp-content/
sudo chmod 775 wp-content/

775 gives read/write/execute to the owner and the group, and read/execute to others. The owner (moritz, UID 1000) and the group (www-data, GID 33) can both write — which is exactly what the container process needs once it's running as 1000:33.

Apply the same ownership to config files you're mounting:

sudo chown moritz:www-data config/php.ini
sudo chown moritz:www-data config/wp-config.php

Putting It Together

Here's the relevant section of a working docker-compose.yml:

services:
  wordpress:
    image: wordpress:latest
    user: "1000:33"
    ports:
      - "8080:80"
    volumes:
      - ./wp-content:/var/www/html/wp-content
      - ./config/php.ini:/usr/local/etc/php/conf.d/custom.ini
      - ./config/wp-config.php:/var/www/html/wp-config.php
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
    depends_on:
      - db

And the setup commands that need to run once before docker-compose up:

mkdir -p wp-content config
sudo chown moritz:www-data wp-content/
sudo chmod 775 wp-content/

After that, docker-compose up -d starts the stack and WordPress at http://localhost:8080 can install plugins, handle uploads, and write to the filesystem without errors.

Quick Diagnostics

If permission errors come back after a restart or a docker-compose down, these two commands tell you what's wrong:

# Host — should show moritz:www-data with drwxrwxr-x (775)
ls -la wp-content/

# Container — should show uid=1000, gid=33(www-data)
docker-compose exec wordpress id

If docker-compose exec wordpress id shows uid=33(www-data), the user: "1000:33" line is missing or hasn't taken effect — bring the stack down and back up after adding it.

If the host ownership is wrong (e.g. owned by root after a previous docker-compose up without the user override), rerun the chown and chmod commands above.

Why Not Use Named Volumes Instead?

Named Docker volumes avoid this problem entirely because Docker manages ownership internally. But for WordPress development, I prefer bind mounts — I can edit theme files, plugins, and uploads directly from the host without going through docker cp or a volume inspector. The permission fix is a one-time setup cost that's worth the convenience.

If you're using Docker for a production-like environment or don't need direct filesystem access, named volumes are simpler. For local web development workflows where you're actively editing files, bind mounts with the UID override are the better choice.

The Docker bind mounts documentation covers the tradeoffs between bind mounts and named volumes in more detail if you want to dig further.

Work with me

Found this helpful?

Get in touch if you need help with your website, SEO, or paid advertising — I offer a free initial consultation.