0

I cloned an existing Laravel project from git which was dockerized with Sail. As vendor is in the .gitignore, I need to rebuild it before I can use Sail to run my app. Acording to the Laravel doc (https://laravel.com/docs/8.x/sail#installing-composer-dependencies-for-existing-projects) i need to get my dependencies using this command.

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

Problem is both cmd and powershell seem to struggle with the $'s, it seams that they expect an applet name, and I can't manage to run this. What am I missing ?

The error I am getting with PS is

id : The term "id" is not recognized as the name of a cmdlet, function, script file or operable program.

In cmd, i got

docker: Error response from daemon: create $(pwd): "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed.

I also tried with git bash and got

docker: invalid reference format: repository name must be lowercase.

Noeudpap
  • 1
  • 1

1 Answers1

2

Only execute the command in the WSL2 Distribution (as example, Ubuntu)

First, Open the wsl console from PowerShell pointing the project folder

wsl -d ubuntu

And then execute the docker command for execute Laravel sail

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

I recommend check your php version for available laravel sail compatibility

When using the laravelsail/phpXX-composer image, you should use the same version of PHP that you plan to use for your application (74, 80, or 81).

Font: Laravel Sail

gera_moran
  • 21
  • 4
  • 1
    yes, i have already tried that and it works well too. But one of the advantage of docker is that it should run the same in every OS. And here i had to install WSL to install dependencies first in my windows OS. – Yash verma Mar 01 '23 at 06:02