Docker: Nginx and php5-fpm dockers are not talking

后端 未结 3 1378
温柔的废话
温柔的废话 2021-02-04 07:48

I’d like to make a fully dockerized Drupal install. My first step is to get containers running with Nginx and php5-fpm, both Debian based. I’m on CoreOS alpha channel (using Dig

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-04 08:45

    The reason it doesn't work is, as you have discovered yourself, that nginx only sends the path of the PHP file to PHP-FPM, not the file itself (which would be quite inefficient). The solution is to use a third, data-only VOLUME container to host the files, and then mount it on both docker instances.

    FROM debian
    VOLUME /var/www
    CMD ['true']
    

    Build the above Dockerfile and create an instance (call it for example: storage-www), then run both the nginx and the PHP-FPM containers with the option:

    --volumes-from storage-www
    

    That will work if you run both containers on the same physical server. But you still could use different servers, if you put that data-only container on a networked file-system, such as GlusterFS, which is quite efficient and can be distributed over a large-scale network.

    Hope that helps.

    Update:

    As of 2015, the best way to make persistent links between containers is to use docker-compose.

提交回复
热议问题