19

I was trying to setup a laravel/sail with docker on the fresh ubuntu install. After following this manual: https://laravel.com/docs/8.x/installation#getting-started-on-linux

I'm getting an Invalid group ID sail error on sail up (alias has been created so I don't need to use ./vendor/bin/sail up anymore).

groupadd: invalid group ID 'sail'
ERROR: Service 'laravel.test' failed to build : The command '/bin/sh -c groupadd --force -g $WWWGROUP sail' returned a non-zero code: 3
idzczakp
  • 313
  • 1
  • 2
  • 9

5 Answers5

40

You can add this to .env file

WWWGROUP=1000
WWWUSER=1000

Both values should be 1000, but you can also get them from bash

id -g <username>
id -u <username>
Andrea Mattioli
  • 873
  • 9
  • 9
  • I've found this to be working solution to the immediate issue but it caused other different problems down the road (of using docker-compose instead of wail wrapper). – peter.babic Sep 08 '21 at 05:40
  • peter.babic, which problems have you found? – Andrea Mattioli Sep 09 '21 at 06:55
  • @andrea-matioli permissions related problems, was not able to pin them down exactly yet. I have also posted a short, not very useful comment Github comment [here](https://github.com/laravel/sail/issues/81#issuecomment-914301837) – peter.babic Sep 10 '21 at 16:21
13

You can solve this by running this before making docker-compose up:

export APP_SERVICE=${APP_SERVICE:-"laravel.test"}
export DB_PORT=${DB_PORT:-3306}
export WWWUSER=${WWWUSER:-$UID}
export WWWGROUP=${WWWGROUP:-$(id -g)}

This is something that sail does every time you run a command with it, but when you run docker-compose directly you need to do it before you run commands with sail.

You can see this here: https://github.com/laravel/sail/blob/1.x/bin/sail#L21

Derk Jan Speelman
  • 11,291
  • 4
  • 29
  • 45
Victor
  • 995
  • 1
  • 10
  • 26
  • 2
    While it probably solves the issue, the real cause is the direct usage of `docker-compose` instead of `sail` script. – Pjotr Oct 13 '21 at 11:09
7

This happens if you run docker-compose up, if you run sail up it will work as intended.

You might need to configure the alias first:

alias sail='bash vendor/bin/sail'
martincarlin87
  • 10,848
  • 24
  • 98
  • 145
  • 1
    The PHP is not installed on docker host, so it is not possible run `composer install` to dependencies then run sail – Ennio Sousa Nov 09 '21 at 12:49
2

I choose to go into the bash of the docker container and 'chown' all the files in www/html/* to 'sail' First to enter bash for sail. sail bash or ./vendor/bin/sail if you didn't set up your alias.

Then you should be in the web root /var/www/html

chown -R sail .

That way, you keep the permisions the same as Laravel intended.

-3

The problem was with the composer itself. After re-installation and clearing docker images it started to build it up!

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
idzczakp
  • 313
  • 1
  • 2
  • 9
  • 2
    I've got that due to running `docker-compose up` directly and not using the `sail up` instead. It seems that the shell script does a lot of additional heavy-lifting. It might be that you've not used `sail` command to do the initial building and that caused some issues. – Pjotr Oct 13 '21 at 11:07