I cannot understand how to get Laradock to work correctly with the mysql db.
I have followed laradock docs and installed everything, spin up containers using
docker-compose up -d nginx mysql
I have the multiple project version layout like such
project
+laradock-spa
The php side seems to work, I can get the laravel welcome page up, however getting the DB connected is causing me issues.
Firstly, where should I be running php artisan commands like php artisan migrate
? Should that be run from my machine within the project folder, or from within the docker container ?
When I run it from my project folder, it works, and I can go into the mysql container and see the initial db tables, like migration
, and user
.
BUT, I cannot get an initial POST to the db to work within Postman - I get error SQLSTATE[HY000] [2002] No such file or directory (SQL: insert into users (...
So I thought maybe I'm supposed to be running the migrate command from within the workspace container, so I bash into the workspace, but from here the php artisan migrate
command errors with [Illuminate\Database\QueryException]
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schem
a.tables where table_schema = spa and table_name = migrations)
As I said, I can successfully get into the mysql container, and login to the DB using root password, and after running first migrations, I can see the tables inside there.
docker ps
shows all containers up.
Can someone explain how it works and how to troubleshoot this ? I'm not sure where I should be running which commands, and how the containers talk to each other. But basically, how can I get the mysql db to work in the laravel project?
Btw, I have local mysql running on the PC too, maybe thats causing some conflict/confusion?
I'm running all this on Win10.