1

I'm new at Docker but I want to use it in order to make easier to organize my production environment. I need an environment with NGINX, PHP 7.2 and Node (and some others); after some digging I used docker-compose:

version: '0.2'
restart: always
services:
    web:
        image: nginx:latest
        container_name: NGINX
        ports:
            - "80:80"
        volumes:
            - ./code:/code
            - ./nginx/conf.d/site.conf:/etc/nginx/conf.d/site.conf
            - ./nginx/sites-enabled:/etc/nginx/sites-enabled
        links:
            - php
    php:
        build: ./php
        container_name: PHP7.2
        volumes:
            - ./code:/code
    composer:
        image: composer:latest
        container_name: Composer
        volumes:
            - ./code:/code
    node:
        build: ./node
        container_name: Node
        volumes:
            - ./code:/code

When I run sudo docker-compose up everything works, however since I'm using a Laravel (5.5) application I have some artisan commands. Some commands scan all application files to populate the database and this process is extremely slow (+10x slower) when comparing to my local environment (Vagrant).

I've researched and apparently volumes have some performance issues; I've tried docker-sync but nothing changed. I really want to make this work but I can't figure out what is going on.

2
  • It would help if you modified your question to add the host OS you are running Docker under. Also, "slow" is a relative term. It would be nice to show some benchmarks (maybe just using the unix time command) that show the commands you are running natively under Vagrant and then under Docker for comparison. If you are comparing to Vagrant it would also be helpful to know the Vagrant configuration (Vagrantfile and any other Vagrant specific commands you run). But generally speaking, volume performance for Docker on Mac and Docker on Windows is pretty abysmal compared to Linux native.
    – Andy Shinn
    Commented Dec 21, 2017 at 2:21
  • I have a similar setup where we wrapped all our composer install, update and requires commands into a php container (the goal is to unify developers environment through docker containers) and the speed varies very significantly between mac and ubuntu for example... Commented Feb 12, 2020 at 16:57

1 Answer 1

2

I believe that this post can help you.

I just only put the flag :cached in mapped volumes and the speed increase is considerable but is not the better solution yet.

1
  • the flag is actually :cached and as you said the improvement are minimal Commented Feb 12, 2020 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.