Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tenzan's avatar

groupadd: invalid group ID 'sail'

Hi,

When I run docker build . I'm having error groupadd: invalid group ID 'sail' in step #10:

Step 9/17 : RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.0
 ---> Running in 890e86dc9889
Removing intermediate container 890e86dc9889
 ---> 1d9edc9362f9
Step 10/17 : RUN groupadd --force -g $WWWGROUP sail
 ---> Running in b573106bfbac
groupadd: invalid group ID 'sail'
The command '/bin/sh -c groupadd --force -g $WWWGROUP sail' returned a non-zero code: 3

Laravel version: "laravel/framework": "^8.12",

0 likes
17 replies
shoe's avatar

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.

7 likes
tenzan's avatar

Interestingly, I don't have Dockerfile under ./vendor/laravel/sail

~/code/laravel/cms-app/vendor/laravel/sail                                                           
total 32
-rw-r--r--  1 askar  staff   819B Jan  6 01:40 CHANGELOG.md
-rw-r--r--  1 askar  staff   1.1K Jan  6 01:40 LICENSE.md
-rw-r--r--  1 askar  staff   1.8K Jan  6 01:40 README.md
drwxr-xr-x  3 askar  staff    96B Jan  6 01:40 bin
-rw-r--r--  1 askar  staff   1.0K Jan  6 01:40 composer.json
drwxr-xr-x  4 askar  staff   128B Jan  6 01:40 runtimes
drwxr-xr-x  3 askar  staff    96B Jan  6 01:40 src
drwxr-xr-x  3 askar  staff    96B Jan  6 01:40 stubs

But I see under /vendor/laravel/sail/runtimes/8.0/Dockerfile or /vendor/laravel/sail/runtimes/7.4/Dockerfile

shoe's avatar

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.

LiamMitchell's avatar

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.

1 like
UhOh's avatar

Ok, need help resolving this. Very annoyed.

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.

1 like
UhOh's avatar

So as of Laravel 8.31 these issues seem fixed. I want to share one discovery about “sail id” error

sail up is not the same as docker-compose up. The latter build will throw the sail error.

So be sure your muscle memory is not accidentally not-using sail.

5 likes
JASCHON's avatar

how can I tell my vscode-dev-container to use "sail up" instead of "docker-compose-up"?

JASCHON's avatar

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

2 likes
pyetrosafe's avatar

@JASCHON with little change...

WWWGROUP=1000
WWWUSER=1000

This works for me! Thanks!

Laravel 9 here! Try to use "docker-compose up" instead "sail up"

2 likes
Rankus's avatar

Hello,

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.

Don't forget to rebuild your sail-8.0/app image :

sail down --rmi all
sail up

You can get the details in Sail Docker files :

https://github.com/laravel/sail/blob/1.x/runtimes/8.0/Dockerfile#L49

https://github.com/laravel/sail/blob/1.x/runtimes/8.0/start-container#L4

https://github.com/laravel/sail/blob/1.x/runtimes/8.0/supervisord.conf#L9

6 likes
Ducati's avatar

Thanks again Rankus! This helped when extending Laravel sail docker-compose file into another container. Cheers! 🍻

1 like
vardaam's avatar

You're awesome, it worked great!

1 like
eibu1812's avatar

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

1 like
sleep's avatar
sudo usermod -aG docker $USER
newgrp docker
vendor/bin/sail up -d

Please or to participate in this conversation.