Replies: 6 comments 1 reply
-
Thank you for starting this discussion. I have tested the commands on my personal machine, running macOS, and the generated files had the appropriate owner permissions for my user. I was able to edit them without any issues. However, as everyone's development environment may vary, I would appreciate more information about the host machine OS and the version of Docker being used in order to reproduce the problem and find a solution. Could you please provide me with that information? |
Beta Was this translation helpful? Give feedback.
-
If you are utilizing Docker images for running a Laravel project, you may want to take a look at the Docker images for Laravel that I have created, which are available here: https://docker.shin.company/laravel |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks for the reply, sure, I am using WSL for Windows 11 on Ubuntu 22.04.1, Docker Desktop 4.15.0 and the folder was created beforehand, hence the $(pwd) because usually if Docker creates that folder it will make it root:root. But yeah, for me, unfortunately, it was all created as root ownership. Please see below, in a fresh folder, ownership is correct, run the command, re-check and all root:root; |
Beta Was this translation helpful? Give feedback.
-
Yes, I think the problem is caused by a mismatch between the user and group ID of the user running the Docker daemon in the WSL environment and the user and group ID of the user in the Windows environment. To fix this, you can either change the user and group ID of the user running the Docker daemon to match the user and group ID of the user in the Windows environment, or you can configure the Docker daemon to use the host's file system instead of the virtualized file system provided by the WSL layer. To change the user and group ID of the user running the Docker daemon, you can use the command: sudo usermod -u <UID> $(whoami) && sudo groupmod -g <GID> $(whoami) Where To configure the Docker daemon to use the host's file system, you can edit the {
"data-root": "/mnt/c/users/<username>/.docker/data"
} Then restart the Docker service. It's important to note that, if you choose this option, you'll need to change the path Regards, |
Beta Was this translation helpful? Give feedback.
-
Hi, sorry for the delay on this one, haven't managed to get back round to this one to do a little additional research myself, but I am confused on this answer. How would I find the Windows uid/gid as this, I believe, is simply a Linux-only thing, there is no uid/gid for Windows machines. Additionally, the sudo command provided, 'sudo' is, again, a linux-only command, so for me to run that in Linux side what uid/gid do I set? Checking my set up, I currently have uid/gid set to 1000 on the WSL environment as that is the default new user IDs, but yeah, I do agree that there is something mismatched because I have tested this project on another PC and yeah, everything was owned by me as expected, but for whatever reason, on my main machine, these are root:root for everything. If you can provide additional information, that would be great, but if not, no worries, I sould hopefully get back to this over the next few days and do some additional research into WSL permissions myself and report back. Thanks. |
Beta Was this translation helpful? Give feedback.
-
I apologize as I only have a MacBook running macOS and was unable to accurately reproduce the issue you are experiencing with WSL. I would greatly appreciate additional information from you, and if there is anything you can suggest for me to improve, I will gladly consider it. |
Beta Was this translation helpful? Give feedback.
-
Hi,
First off, amazing work here, these containers are basically perfect from what I have read through, what you have done is essentially how I'd want to build my own and nearly did before I found your project; thank you!
How do we go about changing the executing user? Just that if I spin up a project using the below;
docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/php:8.2-cli composer create-project laravel/laravel /var/www/html
All files created are root:root, so therefore I cannot edit the files until I have changed the ownership? It seems that once my Laravel project is running, the cache files are created as the PUID/PGID user, but not the initial install nor any container exec commands? e.g. I install a new composer package? For example;
docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/php:8.2-cli composer require spatie/laravel-backup
I am guessing we cannot and this project is very much 'production' containers where you wouldn't edit the code, but I fear that version control would also be affected through update/deployment stages?
Beta Was this translation helpful? Give feedback.
All reactions