Laravel Sail is not working properly in Ubuntu 20.04 LTS - laravel

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.

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

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.

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

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.

Related

How do I run commands in the Vapor UI after deploying Laravel 8 App in Vapor using Docker runtime?

I have been using Laravel Vapor for several years now using native runtimes and have never had an issue until recently when needing to use the Imageick PHP extension. Native runtimes don't support PHP extensions so I decided to try using a docker runtime on a staging server and everything went smoothly until I tried to run the migrate command in the Vapor UI. Getting the following error in Vapor-UI:
sh: /opt/bin/php: not found
Have tried unsuccessfully searching for the location of php in the staging deployment as well as adding alias for php in my dockerfile. Here is my current staging.Dockerfile:
ARG VERSION=php81
FROM laravelphp/vapor:${VERSION}
RUN apk add imagemagick imagemagick-dev php81-pecl-imagick \
&& pecl install imagick \
&& docker-php-ext-enable imagick
COPY . /var/task
Has anyone run in to this issue before? Seems too simple but I have zero experience with Docker and after reading through some documentation I could understand why it wouldn't be available, but then during deployment on vapor I would have thought there would be issues... and if its not available is there any way to access php in the Vapor UI by adding something to the Dockerfile or elsewhere?

How to get laravel sail docker container running on a different computer?

https://laravel.com/docs/9.x/sail
I did a clean Laravel install with Sail on computer 1. It is all setup and working with all containers running (mysql, laravel, redis, etc) and Docker Desktop is showing that it is connected to Windows WSL2 and running in that environment. I never had to install PHP as this install procedure took care of the entire environment.
However, I would now like to pull this repo down on Computer 2 and run it in containers as well. So I pulled down the repo, it didn't have a devcontainers folder, only docker-compose.
I tried running docker compose up and the error is the vendor folder is empty/non existent for obvious reasons.
Now, I could install PHP with the right version and then install composer install and then try again. But that doesn't seem right to me.
Shouldn't I be able to just run this repo as a remote container in Vscode and have it running everything on its own?
How do I get the vendor/bin/sail folders installed?
I went back to computer 1 and created a devcontainer folder using remote-containers, pulled that down onto computer 2 but computer is still does not have the right vendor folder and files to complete the operations.
What am I doing wrong?
Assuming you have Docker working correctly at the second computer, you could run a temporary sail container just to install the composer dependencies in said project, as explained in the Laravel Sail documentation
docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/var/www/html \
-w /var/www/html \
laravelsail/php81-composer:latest \
composer install --ignore-platform-reqs
https://laravel.com/docs/9.x/sail#installing-composer-dependencies-for-existing-projects
After this the temporary container will not exist anymore and you can now run ./vendor/bin/sail up -d normally.

Laravel 'sail up' does not work on production server

I am not sure if I can use laravel sail in production. First question is, can I use laravel sail in production?
And if I can, how can I use laravel sail in production? I am trying to deploy a website using laravel sail. But when I try to execute sail up command, it says Docker is not running. But when I check systemctl status docker, it says Docker is running.
What do I need to do?
Laravel Sail is a development environment so I don't think it's meant for production.
https://laravel.com/docs/8.x/sail#introduction
Docker cannot start on Windows
cmd
"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon
power shell
& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon

Low performance composer with docker for Symfony 3.4

I work with Docker for all my projects, however I have a problem with Symfony 3.4 and Composer with Docker .
When I add some more packages, Composer freezes on update and I need to restart Docker to unblock the situation.
I have no idea whether the problem comes from Symfony or Composer.
I think it's comes from Symfony because when I try with Symfony 4.3 there are no problems.
Can you help me to find a clue to resolve this problem?
Generally, I launch Composer with the following command line:
docker run --rm --name composer -ti -w /var/www -v %cd%:/var/www composer ...
I have resolve my problem,
set 4G RAM for Docker and it work.

Laravel php artisan serve doesn't work

I have Laravel 5.3.16 installed. I have built my projects and until now it would work properly. but for the past few days I can't connect local host. I use the following command on mac terminal,
php artisan serve
and in terminal it's fine, but on my browser I get an error of server being busy!
can anyone tell me what is the problem?
The issue might be that the time you ran 'php artisan' serve wasn't stopped. You can check this by doing following steps:
Assuming you are on a OSX computer:
Open terminal
Run: ps -ef | grep php
Lookup if there is currently a Laravel process in use.
Get that id that is running the instance and kill it.
kill 012345
Try to run the command: php artisan serve again.

Resources