I think this command is a little off
RUN groupadd --force -g $WWWGROUP sail. When I ran this command inside the Ubuntu container it still failed groupadd --force -g www-data sail returned groupadd: invalid group ID 'www-data', but www-data group is a valid.
I commented this line out in ./vendor/laravel/sail/runtimes/8.0/Dockerfile and changed the arg in the docker-compose.yaml in the project root to WWWGROUP: 'www-data' (laravel.test service). After that everything worked as expected.
I'm not Linux savvy enough to understand it fully but it seems like the next command in the Dockerfile is just trying to add the user sail to the www-data group in Ubuntu, which makes sense. That is successful without the previous groupadd command. I'll follow this thread in case we can open an issue.
I'm sure the Sail team has this configured this way to make it very customizable, but it might be helpful to have some docs on what the Dockerfile is expecting for args.
Yeah, you're right. Sorry, that was a typo on my part, it would be under ./vendor/laravel/sail/runtimes/7.4 or 8 depending on the PHP version I think. In my case it was 8. The error should say what Dockerfile it's using.
Fixed the issue by adding below line in docker env file
WORKSPACE_PUID=1000
WORKSPACE_PGID=1000
Source: stackoverflow Thowfeek groupadd invalid group ID 'laradock' error when running docker-compose up
Sorry I can't include link first day I sign up...
Seems like this fixed it but not sure maybe just building it a 2nd time did.
I had previously built it with docker-compose build then I changed the mysql version to 5 7 33 and tried sail build.
After adding those lines to the env and running sail build again it worked.
Why is Sail not building properly? What are the values for WWWGROUP and WWWUSER. Even when I set them to 'www-data' or sail i get the groupadd: invalid group ID errors.
For sanity I tried a brand new laravel new install with sail, and I made sure to delete any old images, etc. and I got the same issue.
Okay, I have a solution that works for me. Hence the error message groupadd: invalid group ID the dockerfile-script tries to run groupadd with a missing parameter. The command should look like groupadd --force -g <Group-ID> sail, while <Group-ID> has to be numeric. So in my case the $WWWGROUP variable was not set in my .env.
Long story short -> I added these lines to my .env and it just worked:
$WWWGROUP=1234
$WWWUSER=sail
Now I can work directly in my Dev Container via VSCode
I think that the Sail's permission strategy is to map the container 'sail' user / group with a local user / group by their IDs. So, both env vars should have numerical values (your personal user on Ubuntu should be 1000) :
WWWGROUP=1000
WWWUSER=1000
The PHP webserver inside the container is ran by the sail user. So, files it creates will belong to sail user and group which will have the same IDs as your local user. Then, you gain access to those resources shared through the Docker volume.
If you are using Laravel Sail, you should use ./vendor/bin/sail up instead of using docker-compose up since the sail command is actually initialized a few environment variables for you out of the box. Let's say if you want to rebuild all the containers, just run ./vendor/bin/sail up --build instead of docker-compose up --build