title: How to sync code between container and host using docker-compose?
body: <p>Until now, I have used a local LAMP stack to develop my web projects and deploy them manually to the server. For the next project I want to use docker and docker-compose to create a mariaDB, NGINX and a project container for easy developing and deploying.</p>
  
  <p>When developing I want my code directory on the host machine to be synchronised with the docker container. I know that could be achieved by running</p>
  
  <pre><code>docker run -dt --name containerName -v /path/on/host:/path/in/container
  </code></pre>
  
  <p>in the cli as stated <a href="https://stackoverflow.com/questions/36650951/sharing-files-between-container-and-host">here</a>, but I want to do that within a docker-compose v2 file.</p>
  
  <p>I am as far as having a docker-composer.yml file looking like this:</p>
  
  <pre><code>version: '2'
  
  services:
      db:
          #[...]
      myProj:
          build: ./myProj
          image: myProj
          depends_on:
              - db
          volumes:
              myCodeVolume:/var/www
  volumes:
      myCodeVolume:
  </code></pre>
  
  <p>How can I synchronise my /var/www directory in the container with my host machine (Ubuntu desktop, macos or Windows machine)?</p>
  
  <p>Thank you for your help.</p>