sajendra
sajendra

Reputation: 437

Laravel Sail is not working properly in Ubuntu 20.04 LTS

Hi i tried to install fresh Laravel project using Laravel Sail docker environment. First it was showing me "Docker is not running" error. Then i found out, i needed to start docker as rootless. I solved it, reading this url: [https://docs.docker.com/engine/install/linux-postinstall/].

After that, I successfully installed Laravel using Laravel Sail. Then I ran

./vendor/bin/sail up -d

I was able to view Laravel project in my browser. But when i ran any other artisan commands such as ./vendor/bin/sail artisan route:list or sail commands as sail shell, all the docker containers were forced closed automatically. It shows me this error.

Sail is not running.

You may Sail using the following commands: './sail up' or './sail up -d'

Any suggestions? I am getting this issue on Ubuntu 20.04 LTS version.

Upvotes: 13

Views: 32583

Answers (6)

Use this Sail is not running.

bash ./vendor/laravel/sail/bin/sail up

Upvotes: 0

Lawrence Edmondson
Lawrence Edmondson

Reputation: 167

A lot of people say this is due to a permission issue. However for me on OSX 12.6.2 (Monterey) it was because Docker is running as my local user and it wasn't in my path. Once I added $HOME/.docker/bin to my path it worked fine.

  • vi ~/.zshrc
  • add $HOME/.docker/bin to your path
  • source ~/.zshrc
  • restart docker desktop
  • ./vendor/bin/sail up

I'm running Docker v4.22 as a local user NOT the system.enter image description here

Upvotes: 0

If you are on Windows and using WSL, make sure the WSL Integration is properly set: Settings->Ressources->WSL Integration + Toggle Linux version

enter image description here

Upvotes: 15

sajendra
sajendra

Reputation: 437

I was using Laradock before installing Laravel Sail. Maybe there were some conflicts. So I backed up all my databases, then I removed all containers using this code. sudo docker rmi -f $(docker images -a -q). Then installed fresh Laravel project and it worked.

Please read my below comment as it is was a better solution for me.

Upvotes: 7

Pirooz Jenabi
Pirooz Jenabi

Reputation: 682

very easy, maybe you don't have permission to run docker. in Linux first use sudo -s and after user ./vendor/bin/sail up -d

Upvotes: 11

Chris
Chris

Reputation: 83

Sail first checks to see if any current docker-compose processes have a status of Exit. If any of them have, then it will forcefully bring down all other services. Which is what you were are seeing whenever you type any sail sub-command. You can see the code here: https://github.com/laravel/sail/blob/87c63c2956749f66e43467d4a730b917ef7428b7/bin/sail#L44-L49

Run sail up to start the processes and then use docker-compose ps to check all services are running and none have an Exit status.

I had the same issue and when reviewing the code and checking my services I noticed the database had exited soon after I brought them up.

Upvotes: 1

Related Questions