20

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

and following dockerfile

FROM php:7.1.0-fpm-alpine

RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli

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 ?

1 Answers1

39

Adding the following to dockerfile fixed the issue.

RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql
Jay Blanchard
  • 33,530
  • 16
  • 73
  • 113