Я занимаюсь разработкой приложения Laravel.Я использую docker-compose для установки моей среды.Я использую Postgres для базы данных.
Это мой docker-compose.yml
version: '3'
services:
apache:
container_name: easy_eat_apache
image: webdevops/apache:ubuntu-16.04
environment:
WEB_DOCUMENT_ROOT: /var/www/public
WEB_ALIAS_DOMAIN: easy-eat.localhost
WEB_PHP_SOCKET: php-fpm:9000
volumes: # Only shared dirs to apache (to be served)
- ./public:/var/www/public:cached
- ./storage:/var/www/storage:cached
networks:
- easy-eat-network
ports:
- "80:80"
- "443:443"
php-fpm:
container_name: easy_eat_php
image: jguyomard/laravel-php:7.2
volumes:
- ./:/var/www/
- ./ci:/var/www/ci:cached
- ./vendor:/var/www/vendor:delegated
- ./storage:/var/www/storage:delegated
- ./node_modules:/var/www/node_modules:cached
- ~/.ssh:/root/.ssh:cached
- ~/.composer/cache:/root/.composer/cache:delegated
networks:
- easy-eat-network
db:
image: postgres
restart: always
ports:
- 5432
environment:
POSTGRES_PASSWORD: secret
volumes:
- easy-eat-data:/var/lib/postgresql
networks:
easy-eat-network:
driver: "bridge"
volumes:
easy-eat-data:
driver: "local"
В файле env Laravel я помещаю учетные данные базы данных, такие как
DB_CONNECTION=pgsql
DB_HOST=db
DB_PORT=5432
DB_DATABASE=postgres
DB_USERNAME=postgres
DB_PASSWORD=secret
Затем я запускаю миграциюКоманда, чтобы увидеть, если мое приложение может подключиться к postgres.Я получил эту ошибку.
Illuminate\Database\QueryException : SQLSTATE[08006] [7] timeout expired (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations)
at /var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[08006] [7] timeout expired")
/var/www/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
2 PDO::__construct("pgsql:host=db;dbname=postgres;port=5432;sslmode=prefer", "postgres", "secret", [])
/var/www/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
Please use the argument -v to see more details.
Как я могу это исправить, пожалуйста?