Docker with nginx and php is very slow

Hello,

First of all Docker is really a great tool, but there is one thing that stops me from using it daily in my development. It’s the performance of the containers. I thought it will be as fast as the host system, but its about 10 times slower. I have nginx image and php-fpm images only slightly modified without any fancy features, and all my apps have response time about 10 times slower on Docker than on the host with similar configuration. In one case it is about 16 seconds - it’s far too much, while it’s 1,5 second when running without Docker. Now I’m wonder if I did something wrong with my configuration? Or is it normal that dockerized services (php, nginx) are just slower? Is this slowness expected? How can i make it run faster?

I’m using Ubuntu bionic as the host. And standard Docker version 18.03.1-ce, build 9ee9f40.

I’ve tried adding cached to volumes, but without luck.

I’m using docker-compose with the following configuration:

version: "3"
services:
    nginx:
        build: ./nginx
        image: pf/nginx:latest
        volumes:
            - ./web:/web/devbox
            - ../panoramafirm:/web/panoramafirm:cached
            - ../budownictwo:/web/budownictwo:cached
            - ../enirocentrum:/web/enirocentrum
        links:
            - php5.6
            - php7.0
            - php7.2
    php5.6:
        build: ./php5.6
        image: pf/php:5.6-fpm
        links:
            - memcached
        volumes:
            - ../enirocentrum:/web/enirocentrum
        environment:
            XDEBUG_CONFIG: remote_host=192.168.0.185
    php7.0:
        build: ./php7.0
        image: pf/php:7.0-fpm
        links:
            - memcached
        volumes:
            - ./web:/web/devbox
            - ../panoramafirm:/web/panoramafirm:cached
            - ../budownictwo:/web/budownictwo:cached
        environment:
            XDEBUG_CONFIG: remote_host=192.168.0.185
    php7.2:
        build: ./php7.2
        image: pf/php:7.2-fpm
        links:
            - memcached
        volumes:
            - ./web:/web/devbox
            - ../panoramafirm:/web/panoramafirm
            - ../budownictwo:/web/budownictwo
        environment:
            XDEBUG_CONFIG: remote_host=192.168.0.185
    memcached:
        image: memcached:latest

2 Likes

Hi @spajak have you found a solution for this problem?

I`m facing the same problem on Docker Windows with NGINX + PHP 7.2-FPM and Postgres

i have the same experience with docker runing nginx and php, do we have some solution here?

Has anyone found a solution to this issue?