Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable php's mysql extensions in docker container? [duplicate]

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 ?

like image 456
Danushka Gunawardena Avatar asked Sep 01 '25 02:09

Danushka Gunawardena


1 Answers

Adding the following to dockerfile fixed the issue.

RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql
like image 139
Danushka Gunawardena Avatar answered Sep 02 '25 16:09

Danushka Gunawardena