title: Docker compose volumes gcc compilation time is super slow
body: <p>I set up a docker with a docker-compose to compile some c code.<br>
  The idea is to use it with vsCode devcontainers. </p>
  
  <p>I have two problems:<br>
  1. With the Docker-compose-1 the compilation is fast but the git inside vsCode dev container sees all the files under sdk as modified.<br>
  2. If I use Docker-compose-2 the compilation is super slow but git is ok in vsCode dev container.</p>
  
  <p>I guess the first problem has to do with how the volumes work in docker but why the compilation is so much slower in the second scenario? </p>
  
  <p>Ideal would be to be able to use git from devcontainer and also have a reasonable time of compilation.</p>
  
  <p>I also tried to add a .dockerignore with sdk but didn't help either.</p>
  
  <p>Any idea or tips would be very much appreciated!</p>
  
  <p>I am using macOS Catalina 10.15.4</p>
  
  <p>Best regards</p>
  
  <pre><code># Dockerfile
  FROM gcc:9.3
  RUN mkdir /code
  WORKDIR /code
  </code></pre>
  
  <pre><code># Docker-compose-1
  version: '3.4'
  
  services:
    app:
      build:
        context: .
        dockerfile: ./Dockerfile
      tty: true
      volumes:
        - ./:/code
        - sdk:/code/sdk
  
  volumes:
    sdk:
  </code></pre>
  
  <pre><code>compilation time is:
    real    0m15.448s
    user    0m6.331s
    sys     0m2.137s
  </code></pre>
  
  <pre><code># Docker-compose-2
  version: '3.4'
  
  services:
    app:
      build:
        context: .
        dockerfile: ./Dockerfile
      tty: true
      volumes:
        - ./:/code
        - ./sdk:/code/sdk
  </code></pre>
  
  <pre><code>compilation time with Docker-compose-2 is:
    real    2m23.196s
    user    0m6.862s
    sys     0m10.658s
  </code></pre>