我是使用 Redis 的新手。我在 Docker 中运行 Laravel、MariaDB 和 Redis。我似乎无法让 redis 正常工作。我在 Laravel Horizon 中收到以下错误:
PDOException:在 /var/www/api/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:46 中找不到驱动程序
我的猜测是代码是在 redis 容器内执行的,它无法访问 PHP 容器。
这是我的 docker-compose.yml:
# Web server
nginx:
image: nginx:latest
restart: always
links:
- socketio-server
ports:
- "3000:3001"
- "8081:80"
volumes:
- ./api:/var/www/api
- ./docker/nginx/conf.d/:/etc/nginx/conf.d
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
links:
- php
# PHP
php:
build: ./docker/php-fpm
volumes:
- ./api:/var/www/api
links:
- mariadb
# Redis
redis:
image: redis:latest
depends_on:
- php
expose:
- "6379"
# Database
mariadb:
image: mariadb:latest
restart: always
ports:
- "3306:3306"
volumes:
- ./database/mariadb/:/var/lib/mysql
# PHP workers
php-worker:
build:
context: ./docker/php-worker
args:
- PHP_VERSION=7.2
- INSTALL_PGSQL=false
volumes:
- ./:/var/www
- ./docker/php-worker/supervisor.d:/etc/supervisor.d
extra_hosts:
- "dockerhost:10.0.75.1"
links:
- redis
有人有什么想法吗?