docker安装并启用php扩展

I trying to use Docker for my Symfony3 project I got it running but I get this error:

The LDAP PHP extension is not enabled.

It does sound right as I am using Ldap extension for my project. I have tried installing the Ldap extension using Dockerfile for my php image which seems to install it but still gives me this error.

Q1) How do I install required php extensions to my php image. Q2) Once extension installed how do i enable it.

docker-compose.yml:

web:
    image: nginx:latest
    ports:
        - "80:80"
    volumes:
        - ./site.conf:/etc/nginx/conf.d/site.conf
 project files
    volumes_from:
        - php
    links:
        - php

php:
    image: php:5.6-fpm
    volumes:
        - ./project_code:/var/www/project

Dockerfile:

FROM php:5.6-fpm

RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install php5-ldap -y

You need to point in your docker-compose.yml to the directory containing your Dockerfile. Then it builds your individual image based on this Dockerfile and links it as desired in docker-compose.

So you have to modify your docker-compose.yml. Lets assume you have stored your Dockerfile in the same directory as your docker-compose.yml file. Then you have to change it as follows:

version: '2'                              # <--
web:
  image: nginx:latest
  ports:
    - "80:80"
  volumes:
    - ./site.conf:/etc/nginx/conf.d/site.conf
 project files
   volumes_from:
     - php
   links:
     - php

php:
  build: .                                # <--
  volumes:
    - ./project_code:/var/www/project

This builds your image as defined in the Dockerfile (currently your Dockerfile is ignored by your docker-compose.yml file). You then have to add to the Dockerfile how to enable your php module.

if you didn't find php.ini with php -i | grep php.ini

In docker, there are two php.ini files: php.ini-development and php.ini-production https://docs.docker.com/samples/library/php/