EscolaLMS / API

Laravel REST API. Main module that compose all Laravel packages
Apache License 2.0
11 stars 7 forks source link

docker compose network redis #324

Closed M-Dominguez closed 8 months ago

M-Dominguez commented 8 months ago

Hi I am wanting to startup a development environment with the docker-compose.yml. I can create all the containers without an issue. But I cannot migrate the database with php artisan migrate i get this error:

 Predis\Connection\ConnectionException

  php_network_getaddresses: getaddrinfo for redis failed: Temporary failure in name resolution [tcp://redis:6379]

  at vendor/predis/predis/src/Connection/AbstractConnection.php:144

I noticed that "redis" in "[tcp://redis:6379]" is from the .env REDIS_HOST=redis. I tried exposing the redis port from the docker and changed "redis" to "localhost". I then got this error:

 Illuminate\Database\QueryException

  could not find driver (SQL: select * from information_schema.tables where table_catalog = default and table_schema = public and table_name = model_fields_metadata and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:760

I assume I am doing something wrong if the docker isnt working properly. How does one start up a project with docker compose?

qunabu commented 8 months ago

Have you tried

docker compose exec escola_lms_app bash -c "php artisan migrate"

M-Dominguez commented 8 months ago

Thank you! That worked!