I have created a local docker development environment of a WordPress instance.
This consists of a git repository
docker, the root of which contains a docker-compose file, then a folder called
data in which I’ve created folders called
├── data │ ├── index.php │ ├── plugins │ ├── themes │ └── uploads ├── docker-compose.yml ├── files │ ├── mysqldump.cnf │ └── uploads.ini └── README.md
docker-compose.yml file simply runs a database image and the official wordpress image from the Docker hub.
version: '3.1' services: db: container_name: website-mysql image: mysql:5.7 restart: always environment: MYSQL_DATABASE: db MYSQL_USER: user MYSQL_PASSWORD: pass MYSQL_ROOT_PASSWORD: rootpass volumes: - ./migrations:/docker-entrypoint-initdb.d - ./files/mysqldump.cnf:/etc/mysql/conf.d/mysqldump.cnf wordpress: container_name: website-wordpress image: wordpress depends_on: - db restart: always ports: - 7070:80 environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_USER: user WORDPRESS_DB_PASSWORD: pass WORDPRESS_DB_NAME: db WORDPRESS_DEBUG: 1 entrypoint: /startup.sh volumes: - ./files/startup.sh:/startup.sh - ./data:/var/www/html/wp-content - ./files/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini volumes: wordpress: db:
The important part here is the line
- ./data:/var/www/html/wp-content where I mount the
data directory to the WordPress
wp-content folder so that WordPress recognises the files in my
data/plugins directory (for example) as plugins on the WordPress instance.
This works fine.
The difficulty I’m having is dealing with permissions across different operating systems. I have 1 user with Linux/Debian, 1 user with MacOS and 1 user with Windows 10 all trying to access this development environment.
I want them to be able to clone this repository, spin up the WordPress instance and install/update plugins as needed, before committing their changes back to the repository.
This doesn’t work smoothly however. It works reasonably well on MacOS, but on Linux there are some files natively owned by
www-data and some by
root. Even when I
chown -R these files to root, and set (what I think are) the right perms using
0644 files), WordPress is unable to install plugins because it can’t create a new folder in the
wp-content folder (e.g.
wp-content/uploads/03/ can’t be created, but
I haven’t even tested Windows yet, but I suspect we’ll have a similar problem - probably manifesting in a different error.
Is there a way I can make these volumes permissible across operating systems, in such a way that WordPress can do everything it needs to do - e.g. creating new files and folders in subdirectories of