简体   繁体   中英

How to modify files in wordpress docker volume?

This is my docker-composer.yml for wordpress:

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     volumes:
      - ./all:/var/www/html
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
   phpmyadmin:
     image: phpmyadmin/phpmyadmin:latest
     ports:
       - "8084:80"
     links:
       - db:db
volumes:
    db_data: {}
   

The folder all contains all the files that ship from the wordpress docker image. However, they all have user/group www-data:www-data and the permission of the files is 644 and from folders 755, ie even if I add myself to the www-data group I have no right to modfiy or create files.


My research:

  • I found at write in shared volumes docker that someone had the opposite problem, he created files and his docker image could not access it. The solution seems to be to run docker and create a file with user www-data - but I don't see how I can apply this to my problem.

  • I tried to add user: "1000:1000 in the worpdress service inside docker-composer.yml , in hope, that all file permissions set by docker would be from my user. However, I get 1000 lines of erros of this form:

wordpress_1 | tar: ./wp-admin: Cannot mkdir: Permission denied wordpress_1 | tar: ./wp-admin/options-reading.php: Cannot open: No such file or directory

I ended up just to change the file permission of all files and folders from folder all to 777 recursively. Since this is only local development, there is no risk involved.

When I create a new file from my host it only has 644 permission, ie it can be read by from localhost but not edited, for that I would manually need to change the permission to 777.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM