本文介绍了如何在php docker映像中启用pdo_mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个基本的Dockerfile
,其中包含以下内容:
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
我有一个docker-compose.yml文件
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"
然后我在项目的根目录下运行docker build -t app . && docker-compose up
.一切似乎都正确构建,但是在输出phpinfo
时,我看不到mysql_pdo扩展名.
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.
我缺少任何步骤吗?
推荐答案
我使用的docker文件是...
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
请注意其中的mysqli和pdo,以允许PDO/mysql位.
Note the mysqli and pdo in there as well to allow the PDO/mysql bit.
这篇关于如何在php docker映像中启用pdo_mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!