A
A
Alexander Pankov2022-02-20 21:14:20
Remote access
Alexander Pankov, 2022-02-20 21:14:20

How to fix permission denied error when working with docker + mutagen?

Hello

, on a laptop (macos), the project code (pure laravel) lies
next to the project code
- docker-compose.yml
- mutagen.yml

The work is built like this
1) The mutagen is configured to synchronize the folder with the project and vps
docker (compose) is installed on the vps itself
2) I go to the project folder and run mutagen, the files immediately appear on the vps and these files have the user that I connect to the vps (id 1000)
here is an example the first line of this is my user, the second is a random project file

uid=1000(pankov) gid=1000(pankov) groups=1000(pankov),27(sudo),998(docker)
-rw-rw-r--  1 pankov pankov    569 Feb 20 11:38 server.php

3) so, I have vps and project files, I run docker-compose build on vps ... inside which the files are mounted (thrown) into the necessary containers (with nginx, php), the docker starts
4) here is the first problem, since the containers are not I know about me (my user), when I go to the project url, I see an error
The stream or file "/application/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied

5) at the same time, if I edit my files in ide, they instantly end up on vps and the container sees these changes and tries to run a new code, everything is as it should
be vps(host machine), respectively, inside the docker, these files with the owner and group www-data
7) try to knock on the nginx port (open the site) - the error is gone - the site is working
8) but there is a new problem, mutagen fell off when synchronizing the file error gives out that he does not have enough rights, it seems logical yes, for example, I edit my index.php, mutagen tries to change it to vps, and on vps the owner of this file is not me (pankov), but www-data

I got lost in 3 pines please tell me why and how to fix it?

Thus, I copy the project files to the vps (via mutagen), the owner of the files becomes the user through which the ssh connection is made (pankov), the docker (its containers) do not know anything about the owner and a rights error is thrown, I put the owner of the project files on www- data (where do I get this www-data from anyway?), the code is executed and the logs are written, but now the rights error is coming from mutagen

those I need:
or do I copy the files through mutagen with the right owner and group right away?
then how do I then and through ssh \ ftp pick

or when mounting files in a container, assign them the right owner and group?
or inside the containers create a copy of my user and make sure that nginx and php are in the same group as my user?

Which option is correct and is there any at all? (I understand that in swimming in the theory of how rights work in linux, even without doekra)

in general, the laptop is weak and I am engaged in remote development, so that the base and php rustle somewhere not with me, but I (the laptop), there was a thin client for updating the code base

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pankov, 2022-02-21
@PankovAlxndr


sudo find recipe . -type f -exec chmod 644 {} \;
sudo find . -type d -exec chmod 755 {} \;
error
The stream or file "/application/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied
chmod -R 775 storage
chmod -R 775 bootstrap/cache
everything works as it should

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question