pdo_mysql extension is not detected on WordPress Docker container

Solution:

Your wordpress image used in this stack is default image of Docker Hub and they have very detail documentation of how to install new PHP extension.

First we have to edit some changes on your docker-compose.yml file to make new wordpress custom build:

wordpress:
     depends_on:
       - db
     container_name: ${CONTAINER_WP_NAME}
     # image: wordpress:latest
     build: ./wordpress

Second, create a new file called Dockerfile and docker-entrypoint.sh of WordPress default image here, place it inside wordpress directory. Amend some magic code to wordpress/Dockerfile file:

RUN docker-php-ext-install pdo pdo_mysql

Now you have your custom Docker stack with PDO_MYSQL extension and able to run your backup process.

Your stack’s config after edit: https://github.com/tdtgit/stackoverflow57447284

Feel free to comment if you need help.