I have a basic Dockerfile
with the following in:
FROM php:7.1-apache RUN apt-get update && docker-php-ext-install pdo_mysql COPY . /var/www EXPOSE 80
I have a docker-compose.yml file
version: "3" services: app: build: . ports: - "80:80" volumes: - .:/var/www depends_on: - mysql mysql: image: mysql:8 ports: - "3306:3306" environment: MYSQL_DATABASE: "app" MYSQL_USER: "app" MYSQL_PASSWORD: "app" MYSQL_ROOT_PASSWORD: "test"
I then ran docker build -t app . && docker-compose up
at the root of the project. Everything seems to build correctly, but when outputting phpinfo
I don't see the mysql_pdo extension.
Are there any steps I am missing?
3 Answers
Answers 1
The docker file I use is...
FROM php:7.1-apache COPY apache2.conf /etc/apache2 RUN docker-php-ext-install mysqli pdo pdo_mysql
Note the mysqli and pdo in there as well to allow the PDO/mysql bit.
Answers 2
There was a similar error in docker php issue 62:
As it turn out that I need to remove the old images and rebuild them again.
Cause I downloaded the image, then edit it. So I need to remove the old image and rebuild it in order to apply the change.
docker rm only removes containers. Make sure you remove your image as well before.
Also check if a Dockerfile like this one might be more robust/complete:
# PHP extensions RUN \ docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \ && docker-php-ext-configure mysqli --with-mysqli=mysqlnd \ && docker-php-ext-install pdo_mysql \ ...
Answers 3
I am using this and works fine for me.
RUN apt-get update \ && apt-get install -y git zlib1g-dev \ && docker-php-ext-install pdo pdo_mysql zip
If its not working for your. Please attache docker build output for review.
0 comments:
Post a Comment