Docker permissions problems to modify a volume anchored in a folder

0

Hi, I'm using docker to set up a small development environment for wordpress because I want to learn something about Docker. Normally I use virtaulHost with apache but I am interested in using the advantages that docker has (I do not want to reconfigure the apache or nginx)

This is the docker-compose.yml file that I found on the official docker page:

version: '3.3'

services:
 #segun entiendo esta es el contenedor de la Base de Datos
 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:
   #Este es dock del wordpress
   depends_on:
     - db
    image: wordpress:latest
    ports:
     - "8000:80"
    restart: always
    #Aqui viene los volumenes es decir yo tengo una carpeta que contiene el docker-compose.yml y 2 carpetas donde irian los plugins y los themas
    volumes:
      - ./plugins/:/var/www/html/wp-content/plugins/:Z # Plugin development
      - ./themes/:/var/www/html/wp-content/themes/:Z # Theme development
   environment:
     WORDPRESS_DB_HOST: db:3306
     WORDPRESS_DB_USER: wordpress
     WORDPRESS_DB_PASSWORD: wordpress
#todavia no entiendo para que es esto
volumes:
   db_data:

What happens is that when I try to edit or create something in those folders I have problems with the permissions. This is quickly solved by adding permissions in the traditional way.

But I would like to know if there is a way to configure the permissions from the docker-compose.yml so that you do not have to use chmod 777 in the folders where I have put the themes and plugins

    
asked by wecbxxx 17.08.2018 в 05:47
source

1 answer

0

Hi, I had the same problem and I solved it in the following way:

1st. before starting the $ docker-compose up -d , create your folder and place the files of the theme you are developing.

2nd. Now you can run $ docker-compose up -d

I'll give you an example:

volumes:
  - ./carpeta_de_tu_tema:/var/www/html/wp-content/themes/carpeta_de_tu_tema/

Docker will automatically create the folder of your theme in the container and link it to the volume of your theme.

I hope I'll help you too I'm just starting in the world of docker.

    
answered by 03.10.2018 в 02:02