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

Time:06-20

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?

CodePudding user response:

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.

  • Related