Answers: <p>I figured this out, and it was related to the opcache settings for PHP in my docker image. The opcache re-validate frequency was set to 60 seconds, meaning that PHP caches files in memory for that long before referring to the filesystem again. Changing this to 2 seconds resolve the issue, but adds a significant performance penalty :(.</p>
  
  <p>See more info: <a href="https://drupal.stackexchange.com/questions/253111/delay-in-code-changes-on-custom-pages-in-drupal-8-in-a-docker-environment">https://drupal.stackexchange.com/questions/253111/delay-in-code-changes-on-custom-pages-in-drupal-8-in-a-docker-environment</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2018-07-12T18:59:22.020Z
Answers: 2018-07-12T18:59:22.020Z
Answers: Brian
Body: <p>Preface: I understand that Docker for Mac has file syncing performance issues, but everything I've read about the issues is related to slow read access. I don't really have a problem with slow read access. My problem is that updates I make to files on my host machine can sometimes take 10+ seconds to update on the running container!</p>
  
  <p>Here's my docker-compose file:</p>
  
  <pre><code>version: '2'
  
  services:
    ps-cms:
      image: [obfuscated]
      container_name: ps-cms
      mem_limit: 2048M
      ports:
        - "9080:80"
        - "9443:443"
      volumes:
        - .:/var/www/html/site:cached
        - ./xdebug.ini:/etc/php/conf.d/docker-php-ext-xdebug.ini
      environment:
        - MYSQL_HOST=ps-db
      networks:
        - connector
      extra_hosts:
       - "mysite.localhost:127.0.0.1"
  
    ps-db:
      image: mysql:5.6
      container_name: ps-db
      mem_limit: 512M
      environment:
        - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      ports:
        - 33006:3306
      networks:
        - connector
  
  networks:
    connector:
  </code></pre>
  
  <p>Software:</p>
  
  <p>Docker Engine: 18.03.1-ce
  Docker Compose: 1.21.1
  Docker Machine: 0.14.0
  PHP Storm: 2018.1</p>
  
  <p>In the Docker for Mac preferences, under "file sharing", I removed everything there and just added my one project folder, since I heard that can affect performance.</p>
  
  <p>Does anyone have advice on what could be causing this sync delay?</p>
  
Comments: CC BY-SA 4.0
Comments: 2018-06-29T07:08:20.053Z
Comments: Try `docker-compose` version 3.
Comments: Benyamin Jafari
Tags: <docker><docker-compose>
Title: Diagnosing large delay in file sync to Docker for Mac
UserDisplayName: Brian
ThreadText: # Diagnosing large delay in file sync to Docker for Mac
  
  (Asked by: username_0 on 2018-06-25)
  
  Preface: I understand that Docker for Mac has file syncing performance issues, but everything I've read about the issues is related to slow read access. I don't really have a problem with slow read access. My problem is that updates I make to files on my host machine can sometimes take 10+ seconds to update on the running container!
  
  Here's my docker-compose file:
  
  ```
  version: '2'
  
  services:
    ps-cms:
      image: [obfuscated]
      container_name: ps-cms
      mem_limit: 2048M
      ports:
        - "9080:80"
        - "9443:443"
      volumes:
        - .:/var/www/html/site:cached
        - ./xdebug.ini:/etc/php/conf.d/docker-php-ext-xdebug.ini
      environment:
        - MYSQL_HOST=ps-db
      networks:
        - connector
      extra_hosts:
       - "mysite.localhost:127.0.0.1"
  
    ps-db:
      image: mysql:5.6
      container_name: ps-db
      mem_limit: 512M
      environment:
        - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      ports:
        - 33006:3306
      networks:
        - connector
  
  networks:
    connector:
  
  ```
  
  Software:
  
  Docker Engine: 18.03.1-ce
  Docker Compose: 1.21.1
  Docker Machine: 0.14.0
  PHP Storm: 2018.1
  
  In the Docker for Mac preferences, under "file sharing", I removed everything there and just added my one project folder, since I heard that can affect performance.
  
  Does anyone have advice on what could be causing this sync delay?
  
  **Tags:** docker, docker-compose
  
  > **Comments:**
  > **username_1**: Try `docker-compose` version 3.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-07-12. Score: 1 | Accepted answer
  
  I figured this out, and it was related to the opcache settings for PHP in my docker image. The opcache re-validate frequency was set to 60 seconds, meaning that PHP caches files in memory for that long before referring to the filesystem again. Changing this to 2 seconds resolve the issue, but adds a significant performance penalty :(.
  
  See more info: <https://drupal.stackexchange.com/questions/253111/delay-in-code-changes-on-custom-pages-in-drupal-8-in-a-docker-environment>
  
  
  ---
  
  