Laravel Sail is not working properly in Ubuntu 20.04 LTS
Asked Answered
M

5

12

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.

Matty answered 27/12, 2020 at 16:16 Comment(4)
Run the command ./vendor/bin/sail up without the "-d" and show what appears.Laaspere
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.Abet
@SantiagoCurvello I am able to view the laravel project in my browser. But when I run some commands for example ./vendor/bin/sail artisan route:list, all the containers, shut down automatically. I dont know why.Matty
@MertMetin I am using 1st party package Laravel Sail (laravel.com/docs/8.x/sail) to setup my dev environment. When I run sail up, all my containers run properly. I can also view my laravel project from my browser. But when I run any other commands such as "sail shell" or "sail artisan route:list", then all of my running containers are shutdown one by one.Matty
M
7

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.

Matty answered 20/1, 2021 at 18:58 Comment(1)
Running these commands also fix this issue. 1. run docker-compose down --volumes 2. run sail up --buildMatty
H
13

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

Hathor answered 2/3, 2022 at 15:53 Comment(1)
Don't forget to restart docker, then restart terminal too.Tamboura
D
10

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

Dependency answered 14/8, 2021 at 17:17 Comment(0)
M
7

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.

Matty answered 20/1, 2021 at 18:58 Comment(1)
Running these commands also fix this issue. 1. run docker-compose down --volumes 2. run sail up --buildMatty
T
1

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.

Townshend answered 24/2, 2021 at 5:26 Comment(0)
B
0

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

Buccal answered 22/8, 2023 at 2:37 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.