Can't run migrations with Docker: php version mismatch
Hi, running on Docker here. The app us running well (default installation demo) but my first attempt to run
php artisan migrate
ended in the following error message:
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2". You are running 7.3.27. in [...]/vendor/composer/platform_check.php on line 24
Why? I believed the reason for using Docker + Sail was having a self contained environment... So no problems with php versions and the like... What am I doing wrong?
@Sinnbeck That didn't work. Or, the command was executed, but an error was thrown. Instead of keep trying to make sail work, at the moment I prefer trying another way, like valet, or even maybe just mamp pro..
@Sinnbeck Hi, yes, I was able to solve at least the php problem. Now when I run sail artisan migrate, I get:
Illuminate\Database\QueryException
SQLSTATE[HY000] [1045] Access denied for user 'sail'@'172.23.0.7' (using password: YES) (SQL: select * from information_schema.tables where table_schema = testsite4 and table_name = migrations and table_type = 'BASE TABLE')
@Sinnbeck shown below. Should I maybe manually add the user (create user)? But if yes, where can I fine the host IP informations? Is the IP fixed/static for each container?
@stratboy It should be automatically added when your create container the first time. It creates a volume where the data is saved. I honestly cant think of reason why deleting the volume didn't work. I google a bit and people tend to agree that the solution I suggested is how you rebuild it.
@Sinnbeck I know, but here doesn't work. Probably I'll go back to mamp or valet. Quite disappointed though (not with you all, obviously, but with Laravel), because Docker is currently presented as the easier, zero config solution. It's not, not in every case. I found several posts on google about people struggling with my very same issues (and stil I didn't find any solution anyway).
So I should study Docker from the inside, which definitely it's not what's supposed to be done by a guy trying to learn Laravel (and not Docker). It's simply a pity, in my own opition..
@Sinnbeck Hi! I finally managed to get it working. I really don't know what was the problem. I just tried to completely delete the container and reinstall everything again on another folder, starting again with curl -s "https://laravel.build/example-app" | bash and all went fine for now, migrations included.
@stratboy Because the version of PHP in a Docker image might be different to the version of PHP installed on your computer, hence the version mismatch error.