1

I'm using a very simple docker-compose file:

version: '2'
services:

db:
  image: mysql:5.7 # https://hub.docker.com/_/mysql/ - or mariadb https://hub.docker.com/_/mariadb
  container_name: prestashop_db
  ports:
    - 3306:3306 # change ip if required
  volumes:
    # for init 
    - ./db-init:/docker-entrypoint-initdb.d # IMPORTANT ! comment after the first docker-compose up 
    - ./db-data:/var/lib/mysql
  environment:
    MYSQL_ROOT_PASSWORD: root
    MYSQL_DATABASE: prestashop
    MYSQL_USER: docker
    MYSQL_PASSWORD: docker     
  restart: unless-stopped

prestashop:
  image: prestashop/prestashop:1.7-7.2-apache
  container_name: prestashop_www
  ports:
    - 127.0.0.1:80:80 # change ip if required
  volumes:
    # sites directory: add the sources
    - ./src:/var/www/html
  environment:
    DB_SERVER: "db:3306"
    DB_USER: docker
    DB_PASSWD: docker
  depends_on:
    - db
  links:
    - db:db 

All the content generated in my src directory, which actually corresponds to prestashop code, has the www-data:www-data owner. This means I can't actually edit it. If I change permissions or create any files as the host user, I get permission errors in the service because my user is not mapped.

I'd like to ask docker to map my host user to the www-data user in the prestashop service and specify it in the docker-compose file. Is it possible? This is something I used to do with LXC containers and was very useful.

I'd like not to: * Run any scripts to change permissions or add my user to the www-data group in my host machine

Thanks for your help

PauGNU
  • 783
  • 3
  • 12
  • 32
  • You can run commands like `chown -R` to change permissions on files and folder – HRK44 May 17 '19 at 12:34
  • Do any of these answers help: https://stackoverflow.com/a/56023211/596285 https://stackoverflow.com/a/56060521/596285 https://stackoverflow.com/a/37715761/596285 https://stackoverflow.com/a/55182906/596285 https://stackoverflow.com/a/53915137/596285 – BMitch May 17 '19 at 13:50
  • Thanks @BMitch, the first answer seems to be a good approach. I think it's weird not having a quick solution for this issue using docker-compose. Does it mean that everyone developing with docker machines do all these workarounds to get it working? – PauGNU May 18 '19 at 15:17
  • @PauGNU There are lots of options, each with pros and cons, but I had put together the fix-perms script because I kept running into the cons from various other options. The second link is probably best at summarizing: https://stackoverflow.com/a/56060521/596285 – BMitch May 18 '19 at 17:40

0 Answers0