docker icon indicating copy to clipboard operation
docker copied to clipboard

Docker Compose not working: PDO driver mismatch

Open mcblum opened this issue 4 years ago • 6 comments

Ok so I'm trying to install Wallabag and use MySql as a DB. The provisioner has failed every time, so I exec into the container and run php /var/www/wallabag/bin/console wallabag:install --env=prod -vvv which gets me this:

Screen Shot 2021-04-09 at 1 32 29 PM

In that list, pdo_sqlite is wrong, it should be MySql. I've verified it's set: Screen Shot 2021-04-09 at 1 34 55 PM

It then tells me that my DB appears to be there, would I like to reset it. I say yes and get: Screen Shot 2021-04-09 at 1 32 43 PM

Which is an exception thrown my the MySql driver, not sqlite.

Does anyone know what's going on? My docker-compose file is an exact copy of the one in the example.

mcblum avatar Apr 09 '21 18:04 mcblum

I should add that MariaDB is also running in docker, and the DNS lookup works: Screen Shot 2021-04-09 at 1 37 03 PM

And that if I try to manually run the migrations, it says everything is up to date even though no wallabag DB has even been created in MySQL: Screen Shot 2021-04-09 at 1 39 47 PM

mcblum avatar Apr 09 '21 18:04 mcblum

I'm going through a MySQL -> PgSQL migration now and I have this same problem - the installer is defaulting to the sqlite database not pgsql despite the environment variable being set and recognized inside the container.

eric-pierce avatar May 02 '21 18:05 eric-pierce

@mcblum I believe I was able to solve this.

I deleted my downloaded images and container, as well as my local data folder. I included the environment variable "POPULATE_DATABASE=False" I then re-downloaded the docker container. After it had initialized, I ran the following commands:

sudo docker exec -t wallabag /var/www/wallabag/bin/console cache:clear --env=prod sudo docker exec -t wallabag /var/www/wallabag/bin/console wallabag:install --env=prod --no-interaction

The cache clearing is what appears to be missing during setup, and enabled the installer to recognize that I wanted to use postgresql instead of sqlite.

As long as the "POPULATE_DATABASE=False" is set, then you shouldn't need to clear cache with each restart, but if it isn't then the cache needs to be cleared with each restart, or the issue reverts.

eric-pierce avatar May 02 '21 22:05 eric-pierce

@eric-pierce , got it working with the info you provided, thanks! It looks like the POPULATE_DATABASE did the trick, I also added some other stuff (see below) but it's working so didn't investigate if they were needed in the end or not.

Just as reference and maybe of help to someone, my setup consists of:

  • Wallabag running in docker on a Helios64, had to build the docker manually but no problems encountered.
  • Postgres DB running in docker

I added the wallabag user/db manually to the postgres DB-docker before starting the wallabag-docker, I first thought wallabag had issues creating the user/db but after running the command provided by @mcblum php /var/www/wallabag/bin/console wallabag:install --env=prod -vvv, I saw that wallabag indeed did not take the pdo_pgsql into account even though the environment variable was correct.

Wallabag docker-compose:

version: '3'
services:
  wallabag:
    image: local/wallabag:2.4.2 # docker built manually
    container_name: wallabag
    restart: unless-stopped
    network_mode: bridge
    environment:
      - SYMFONY__ENV__DATABASE_DRIVER=pdo_pgsql
      - SYMFONY__ENV__DATABASE_DRIVER_CLASS="Wallabag\CoreBundle\Doctrine\DBAL\Driver\CustomPostgreSQLDriver"
      - SYMFONY__ENV__DATABASE_HOST=server.lan
      - SYMFONY__ENV__DATABASE_PORT=5432
      - SYMFONY__ENV__DATABASE_NAME=wallabag
      - SYMFONY__ENV__DATABASE_USER=wallabag
      - SYMFONY__ENV__DATABASE_PASSWORD=wallabagpassword
      - SYMFONY__ENV__DOMAIN_NAME=https://wallabag.myurl.com
      - SYMFONY__ENV__SERVER_NAME="My wallabag"
      - SYMFONY__ENV__FOSUSER_REGISTRATION=false
      - SYMFONY__ENV__FOSUSER_CONFIRMATION=false
      - POPULATE_DATABASE=false
    ports:
      - 80
    volumes:
      - ./volumes/data:/var/www/wallabag/data
      - ./volumes/images:/var/www/wallabag/web/assets/images
    labels: # traefik stuff
      - "traefik.enable=true"
      - "traefik.http.routers.wallabag.rule=Host(`wallabag.myurl.com`)"
      - "traefik.http.routers.wallabag.entrypoints=websecure"
      - "traefik.http.services.wallabag.loadbalancer.server.port=80"
      - "traefik.http.routers.wallabag.service=wallabag"
      - "traefik.http.routers.wallabag.tls=true"
      - "traefik.http.routers.wallabag.tls.certresolver=mytlsresolver"

laurensmiers avatar May 11 '21 11:05 laurensmiers

Ran into the same issue. Workaround fixed it, but isn't optimal.

m3nu avatar Mar 18 '22 10:03 m3nu

Same issue, workaround worked.

I'm using postgres, similar to the compose set up shown in the README.md

Before running those commands the database wouldn't be initialised when a new container is created. Running those commands got the database to populate, but then trying to log in would throw an exception complaining about file write permissions within the container. I removed & recreated the wallabag container (but left the initialised database) and things seem to be working for the moment.

leviwheatcroft avatar May 17 '22 21:05 leviwheatcroft