36

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 ?

0

1 Answer 1

69

Adding the following to dockerfile fixed the issue.

RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql
Sign up to request clarification or add additional context in comments.

3 Comments

in the original post , its bit different, pdo parts are missing in it.
Thank you for this! I think the mysqli bit is not really required. It's an extension apart from PDO.
Yes, mysqli and pdo are separate. In my case I needed it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.