0

I'm setting up a small environment using three docker containers (nginx, PHP, mysql). Everything works fine. Sites are beiing displayed, php is beiing processed etc.
I began encountering problems, when I started setting up database connections. Neither mysqli nor PDO seem to work. I "uncommented" the extension in the php.ini file. But it seems the the actual extensions are missing.
On Startup PHP tells me the following:

"Unable to load dynamic library 'pdo_odbc' ...... cannot open shared object file: No such file or directory"

I get this message multiple times for every extension I enabled in the php.ini file.
This makes sense, because the only two files present in my extension_dir are "opcache.so" and "sodium.so". So I tried to install the extensions manually by using the following command(s):

apt-get update
apt-get install php7.0-mysql

Result:

Building dependency tree
Reading state information... Done
E: Unable to locate package php7.0-mysql
E: Couldn't find any package by glob 'php7.0-mysql'
E: Couldn't find any package by regex 'php7.0-mysql'

I've been browsing the forums for days now. There are a lot of similar questions. But I haven't been able to extract answers to the following basic question:

How do I install extensions for PHP inside a Docker-container? OR What am I doing wrong? ^^

By the way: This is the first question I post on StackOverflow. So please apologize If I detail one aspect too much and another one not enough. Constructive criticism of my "style of asking questions" is highly appreciated.

MaxB
  • 35
  • 6
  • Does this https://stackoverflow.com/q/37527803/80836 help? – Andreas Feb 07 '21 at 13:20
  • I added the following to the Dockerfile of my php-container: `RUN docker-php-ext-install pdo pdo_mysql pdo_pgsql`, but no additional php-extensions are beeing listed when I access the container via **docker exec** and type `php -m` – MaxB Feb 07 '21 at 13:56
  • 2
    After `docker-php-ext-install` you may need to call `docker-php-ext-enable` as well. `install` only makes them available, `enable` actually enables them. – rickdenhaan Feb 07 '21 at 14:14
  • I changed the command to `RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli` but mysqli doesn't apper after typing `php -m` – MaxB Feb 07 '21 at 14:31

0 Answers0