如何在 docker 容器中启用 php 的 mysql 扩展?
我有以下 docker-compose.yml
i have the following docker-compose.yml
web:
image: nginx:1.17.1-alpine
ports:
- "80:80"
volumes:
- ./code:/code
- ./site.conf:/etc/nginx/conf.d/site.conf
links:
- php
php:
build: .
volumes:
- ./code:/code
links:
- mysql
mysql:
image: yobasystems/alpine-mariadb:latest
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=password
并关注 dockerfile
and following dockerfile
FROM php:7.1.0-fpm-alpine
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
在此设置中,永远不会安装 php 的 mysql 扩展或 docker mysql 扩展.我无法从 php 容器访问 mysql.adminer.php 抱怨说支持的 PHP 扩展(MySQLi、MySQL、PDO_MySQL)都不可用."
In this setup , php's mysql extensions or docker mysql extensions never get installed. i cannot access mysql from php container. adminer.php complains saying "None of the supported PHP extensions (MySQLi, MySQL, PDO_MySQL) are available."
我们如何解决这个问题?
How do we fix this problem ?
推荐答案
将以下内容添加到 dockerfile 解决了该问题.
Adding the following to dockerfile fixed the issue.
RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql
相关文章