A docker wpcli setup using tatemz/wp-cli which can be built locally to use current user and www-data group.
The problem: in Linux docker uses www-data
as the user executing wp-cli commands. This is fine for the wordpress container, but when it comes to developing files on linux we need shared permissions on the files.
This repo mainly exists to remind me how to fix this problem in the future. It's not intended to be a robust solution for everyone to use.
Builds a local wpcli
image with your current user using the default group www-data
for commands.
- Checkout this repo and open your terminal in that directory.
- Run:
docker build -t wpcli \
--build-arg USER_ID=$(id -u) \
- Edit your docker-compose file if used:
wpcli:
image: wpcli
volumes:
- ./:/var/www/html
- ./wp-content:/var/www/html/wp-content
depends_on:
- db
entrypoint: /bin/wp-cli.phar
command: --info
The important parts above:
image: wpcli
To select the image we just built.
and
entrypoint: /bin/wp-cli.phar
To override Tatemz's sh script that runs as www-data.
You might ask why even base this on tatemz docker, since that script is probably the main thing being provided, and you might be right.
Docker Shared Permissions from vsupalov.com - Explanation of permissions in docker/linux with some general solutions Tatemz Docker wp-cli - Go-to for wp-cli in docker