Laravel Sail won't build on Ubuntu 20.04 - groupadd: invalid group ID 'sail'

Viewed 13145

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
5 Answers

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>

You can solve this by just run 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 do every time you run a command with it, but when you run docker-compose directly you need to do it before.

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

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'

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.

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

Related