Skip to content
Advertisement

Symfony, Docker container fpm, apache : could not find driver [doctrine:database:create]

I’m trying to create symfony 5.4 project using docker with a container for apache, php fpm, symfony, mysql db. but actualy i don’t succed to create my database, i get this error:

JavaScript

this doctrine conf : config/packages/doctrine.yaml:

JavaScript

this is extensions activated :

JavaScript

this my Docker-compose-stack-file:

JavaScript

and My file .env:

JavaScript

Advertisement

Answer

  1. Are you sure you are running php -m on the docker container and not your host?(quite common mistake)

  2. In your symfony(fpm) docker container 127.0.0.1 and localhost resolve to the container itself, not your host machine which has the db exposed on port 3309. Try changing your DATABASE_URL to mysql://root:root@myApp-back-db:3306. Also, you can try setting url to host.docker.internal if you are on mac or windows.

  3. Create a docker file for fpm and install mysql ext:

docker-composer:

JavaScript

Dockerfile:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement