Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Geddit's avatar

Redis + Docker: PDOException: could not find driver

I'm new to using Redis. I'm running Laravel, MariaDB, and Redis in Docker. I can't seem to get redis to work properly. I get the following error in Laravel Horizon:

PDOException: could not find driver in /var/www/api/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:46

My guess is that the code is being executed inside the redis container, that has no access to the PHP container.

This is my 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

Anyone any ideas?

0 likes
1 reply
Geddit's avatar
Geddit
OP
Best Answer
Level 4

It turns out that I hadn't installed pdo_mysql in the 'php_worker' container. Silly me.

Please or to participate in this conversation.