Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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


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
like image 995
idzczakp Avatar asked Apr 23 '21 05:04

idzczakp


People also ask

Can I build a Laravel project using Docker and sail?

I'm creating a new laravel project using docker and sail, i'm on Windows 10, I have enabled WSL 2 and all that was required in the docs, but after I create the laravel project in the ubuntu shell (Ubuntu 20.04), and build sail using the following commands

What is the error code for sail build?

Build Error ( Sail up / Sail Build ): "gpg: keyserver receive failed: Server indicated a failure." #383 Build Error ( Sail up / Sail Build ): "gpg: keyserver receive failed: Server indicated a failure." #383 PHP Version: 8.1.

Why is my sail shell not working?

Run the command ./vendor/bin/sail up without the "-d" and show what appears. How are you creating your containers? Are you using docker-compose? There's probably an error happening in your container (s) and they are not created. So since you have no containers running, sail shell also doesn't work.


Video Answer


4 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>
like image 180
Andrea Mattioli Avatar answered Oct 06 '22 20:10

Andrea Mattioli


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

like image 31
Victor Avatar answered Oct 06 '22 19:10

Victor


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.

like image 2
user1552364 Avatar answered Oct 06 '22 18:10

user1552364


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'
like image 7
martincarlin87 Avatar answered Oct 06 '22 20:10

martincarlin87