<p>i've problem when i run a php deployment with kubernetes becouse don't load the modules or extensions libraries.</p>

<p>My deployment file is this:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: php
  labels:
    app: php
spec:
  selector:
    matchLabels:
      app: php
  replicas: 1
  template:
    metadata:
      labels:
        app: php
    spec:
      containers:
      - name: php
        image: php:7-fpm
        env:
          - name: PHP_INI_SCAN_DIR
            value: :/usr/local/etc/php/conf.custom
        ports:
        - containerPort: 9000
        lifecycle:
          postStart:
            exec:
              command: ["/bin/sh","-c","docker-php-ext-install pdo pdo_mysql mysqli &amp;&amp; docker-php-ext-enable pdo pdo_mysql mysqli"]
        volumeMounts:
          - name: php-conf
            mountPath: /usr/local/etc/php/conf.custom
      volumes:
        - name: php-conf
          configMap:
            name: php
</code></pre>

<p>And my ConfigMap is this:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: php
  labels:
    app: php
data:
  wordpress-custom.ini: |-
    upload_max_filesize = 100M
    post_max_size = 100M
  default.ini: |-
    extension=pdo_mysql.so
    extension=mysqli.so
</code></pre>

<p>Later i go into the Pod with command "exec -it" and i put again "docker-php-ext-enable mysqli" to check it, but i receive the message "warning: mysqli (mysqli.so) is already loaded!", but when i run the "phpinfo()" command, i see "upload_max_filesize = 100M" and "post_max_size = 100M" updated, but i can't see modules enabled.</p>

<p>What i can do? very thank's</p>

O.Palm
<p>The problem is that your docker CMD is to run php-fpm </p>

<p><a href="https://github.com/docker-library/php/blob/bb16de8a711d1ba1dc76adf4665b3b1c06a06922/7.3/stretch/fpm/Dockerfile#L266" rel="nofollow noreferrer">https://github.com/docker-library/php/blob/bb16de8a711d1ba1dc76adf4665b3b1c06a06922/7.3/stretch/fpm/Dockerfile#L266</a></p>

<p>and after container started you cannot change loaded to memory php configuration. </p>

<p>You need to restart php-fpm to apply changes, but restart kills container and you loose all changes. To add some libraries for php you should to create your own docker image and install all your libraries into the image instead of installing it in runtime.</p>

<p>Check also this issue on github
<a href="https://github.com/docker-library/php/issues/331" rel="nofollow noreferrer">https://github.com/docker-library/php/issues/331</a></p>

<p>So answer is to create your own image and install all required extensions with docker RUN command</p>

<pre><code>FROM php:7-fpm

RUN apt-get install php-pdo php-mysql 
</code></pre>

<p>After that you have to build this image</p>

<pre><code>docker build -t php:7-fpm-mysql .
</code></pre>

<p>push it to some docker registry. For example hub.docker.com</p>

<pre><code>docker push php:7-fpm-mysql
</code></pre>

<p>NOTE: php mysql extension is deprecated since PHP 5.5.*, use PDO instead</p>
