DB library
Closed this issue · 6 comments
Hi, I have a problem - there is no library for the database in php (for example, mysqli.so). How can I add a library (mysql, pgsql, oracle db - any) to php?
Hi. This can help https://github.com/docker-library/docs/tree/master/php#php-core-extensions.
You can do it with the command in Dockerfile
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
For example, create new Dockerfile
FROM rnix/php-fpm-gost
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
Then build it:
docker build . -t php-gost
And run:
docker run php-gost
It is safer to create your own Dockerfile, just copy all contents from my https://github.com/rnixik/docker-openssl-gost/tree/master/php-fpm-gost
and add you install commands.
Unable to load dynamic library 'mysqli.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/mysqli.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/mysqli.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/mysqli.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/mysqli.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
after this command and run:
FROM rnix/php-fpm-gost RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
I try install package:
ROM rnix/php-fpm-gost RUN apt-get update && apt-get install -y \ php-mysql php-mysqli php7.0-mysql php-mysqli\ && docker-php-ext-install mysqli && docker-php-ext-enable mysqli
and get this:
E: Package 'php-mysql' has no installation candidate E: Package 'php-mysqli' has no installation candidate E: Package 'php7.0-mysql' has no installation candidate E: Package 'php-mysqli' has no installation candidate
has no installation candidate
Take a look https://github.com/docker-library/docs/tree/master/php#e-package-php-xxx-has-no-installation-candidate
I am a new user of the docker, maybe I do not quite understand. If i create new Docker file like this
FROM rnix/php-fpm-gost RUN rm /etc/apt/preferences.d/no-debian-php && apt-get update && apt-get install -y \ php-mysql \ && docker-php-ext-install mysqli && docker-php-ext-enable mysqli
no error, but container no have any changes.
If i git clone your repo, add my command - i have error like this
Sending build context to Docker daemon 27.14 kB Step 1/36 : FROM rnix/openssl-gost AS openssl-gost Error parsing reference: "rnix/openssl-gost AS openssl-gost" is not a valid repository/tag: invalid reference format Step 2/36 : FROM debian:stretch-slim ---> 3e235dbb0ba6 Step 3/36 : COPY --from=openssl-gost /usr/local/ssl /usr/local/ssl Unknown flag: from
- Did you build this Dockerfile into image with your own tag and run container from this image?
- Try to update your docker.
I'm remove old images sudo docker-compose rm and after that php started and connected to mysql. Thank you very much for your help!