I am suffering with a very strange and annoying problem… I am driving the situation crazy:
I have created a docker container that has the following configurations:
Dockerfile
# Dockerfile
FROM php:8.3-fpm
# PHP INI
COPY /docker/php/php.ini /usr/local/etc/php/php.ini
# Install dependencies
RUN apt-get update && apt-get install -y
libpng-dev
libjpeg62-turbo-dev
libfreetype6-dev
zip
unzip
git
curl
libonig-dev
libxml2-dev
libpq-dev
&& docker-php-ext-configure gd --with-freetype --with-jpeg
&& docker-php-ext-install pdo_mysql pdo_pgsql mbstring pdo pgsql exif pcntl bcmath gd
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www-data:www-data . /var/www
# Install Composer dependencies
RUN composer install --prefer-dist --no-progress --no-interaction --no-dev
# Expose port 9000
EXPOSE 9000
# Start Laravel Octane
CMD ["php", "artisan", "octane:start", "--server=frankenphp", "--host=0.0.0.0", "--port=9000"]
docker-compose.yml
services:
frankenphp:
image: dunglas/frankenphp
container_name: frankenphp
restart: unless-stopped
ports:
- "8000:80"
- "443:443"
volumes:
- .:/app
- ./certs:/certs
- ./docker/caddy/Caddyfile:/etc/caddy/Caddyfile
networks:
- app-network
db:
image: postgres:14-alpine
container_name: db
ports:
- "5432:5432"
volumes:
- ~/apps/postgres:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=password
networks:
- app-network
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
restart: unless-stopped
volumes:
- pgadmin_data:/var/lib/pgadmin
ports:
- "8080:80"
environment:
- [email protected]
- PGADMIN_DEFAULT_PASSWORD=password
networks:
- app-network
php:
build: .
container_name: php
volumes:
- .:/var/www
working_dir: /var/www
networks:
- app-network
composer:
image: composer:latest
container_name: composer
volumes:
- .:/app
working_dir: /app
networks:
- app-network
entrypoint: [ "composer" ]
redis:
image: redis:6-alpine
container_name: redis
ports:
- "6379:6379"
command: redis-server --requirepass "password"
networks:
- app-network
npm:
image: node:latest
container_name: npm
volumes:
- .:/app
working_dir: /app
networks:
- app-network
command: npm install
volumes:
pgadmin_data:
networks:
app-network:
driver: bridge
.env
DB_CONNECTION=pgsql
DB_HOST=db
DB_PORT=5432
DB_DATABASE=app
DB_USERNAME=app
DB_PASSWORD=password
I have created a database app as well as privileges for the user app
When I start:
docker compose up –build -d
then I run:
docker compose run –rm php php artisan migrate OR docker compose run –rm php php artisan migrate:fresh
Everything works and the tables are uploaded to the database.
But when I open the app I get the error:
could not find driver (Connection: pgsql, SQL: select * from "sessions" where "id" = YVQKOF5zkNoZv4yfC3A5MlcU64hYyD8gG9tv8O7o limit 1)
nothing is written in the sessions table and it gives an error in the driver. I can’t figure out where the problem is… I’d be glad if someone has come across this to help me.
thanks in advance
I have even added an external php.ini file in which I have added:
upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 60
memory_limit = 256M
extension=php_pgsql.so
installs correctly everywhere:
docker-php-ext-install pdo_mysql pdo_pgsql mbstring pdo pgsql geolocation pcntl bcmath gd
But things don’t work out.
2
Answers
As a laravel developer, if you are encountering this issue on your Laravel App:
could not find driver (Connection: pgsql, SQL: select * from "sessions" where "id" = irm9IMFseLaF0DyyRzZUNbgkJeybu1UoT8cS7e9s limit 1)
Step 1: Put off your Local Server (Laragon, Xamp or Wamp or any other server)
Step 2: Navigate to your php.ini file
Do make sure you allow these extensions on your php.ini file on your local server:
.env:
You aren’t using the php service for your app. Your ports are configured on the frankenphp service which you haven’t added that extension to.