<p>I have nginx and php-fpm containers in Google Container Engine and I would like to run it through unix socket instead of network.</p>

<p>I also have the Google SQL Proxy container and it uses empty volume to provide connection to Google SQL databases through sockets placed on that volume that is shared with other containers. So I was thinking of using the same approach for PHP but it is not working.</p>

<p>I have empty volume of emptyDir type mounted to php and nginx containers. The volume is mounted, I can see it in both containers. But if I try to use nginx I will get (socket)file not found in logs.</p>

<p>I have also added the www-data(same uid as in php container) user into nginx container and set it in nginx conf but it didn't help.</p>

<p>Is Google SQL Proxy special in some way and I have to use network for PHP or am I missing something here?</p>

<p>I managed to get the approach you described working. I use a <code>emptyDir</code> in a <code>deployment</code> so a shared <code>/sock</code> folder is mounted to both nginx and fpm:</p>

<pre><code>  - name: fpm
    ...
    volumeMounts:
    - name: php-socket
      mountPath: /sock
    ...

  - name: nginx
    ...
    volumeMounts:
    - name: php-socket
      mountPath: /sock
    ...

  volumes:
  - name: php-socket
    emptyDir: {}
</code></pre>

<p>I found this article helpful for the actual nginx and fpm configuration: <a href="https://medium.com/@shrikeh/setting-up-nginx-and-php-fpm-in-docker-with-unix-sockets-6fdfbdc19f91" rel="noreferrer">https://medium.com/@shrikeh/setting-up-nginx-and-php-fpm-in-docker-with-unix-sockets-6fdfbdc19f91</a></p>

<p>The snag I hit was a file in my php-fpm docker container config called <code>zz-docker.conf</code> which contains <code>listen = [::]:9000</code>. Since the name of the file is alphabetically high, it was clobbering my other config file, stopping the unix socket communication working (i.e. <code>listen = /sock/php.sock</code>). I removed the problem line using this in the <code>Dockerfile</code>:</p>

<pre><code>sed -i -e ‘/listen/d’ /usr/local/etc/php-fpm.d/zz-docker.conf
</code></pre>
