1
votes

I have run a docker container for local development (mysql container and prestashop container as described in docker hub). Also mounted volumes to both containers.

But when editing files in my computer with for example sublime text, I cannot create any file because in docker files owner is www-data:www-data.

Tried chown volume files to my user:group but of course, it breaks the site...

Also followed theses steps for linux and docker https://docs.docker.com/install/linux/linux-postinstall/ (to Manage Docker as a non-root user)

$ docker network create prestashop-net
$ docker run -ti --name mysql57 --network prestashop-net -e MYSQL_ROOT_PASSWORD=admin -p 3307:3306 -v /home/nicolas/docker/db-persist/mysql5.7:/var/lib/mysql --user $(id -u):$(id -g) -d mysql:5.7
$ docker run -ti --name ps1751 --network prestashop-net -e DB_SERVER=mysql57 -p 8080:80  -v /home/nicolas/Dropbox/proyectosWeb/docker/ps1751:/var/www/html --user $(id -u):$(id -g) -d prestashop/prestashop

What step am I missing here to be able to edit/create/delete files from sublime text (files that are inside container)?

I want to be able to add/delete/edit files from my host and sublime text editor without permission problems.

Thanks!

1

1 Answers

0
votes

Ok finally after testing several docker images, this one worked ok https://aboullaite.me/dockerizing-your-lamp-enviroment/.

I think for some reason (sorry new to docker), the prestashop image is a minimal setup and it's not mapping UID nor GID from the host to the container... so it's impossible to modify any file from the host without sudo it.

This line in the Dockerfile did the trick "RUN usermod -u 1000 www-data" but of course, my user (in my computer) is GID = 1000 and group of the user that runs inside container is www-data (user is also www-data, because it is an apache server) and it works because of that. If my user had a different GID and group inside container was different, it would need some changes.

But for an apache enviroment that was what I was looking for, it works perfect, and now I can create/delete and modify files inside container from my computer in my sublime editor withour permission problems.