Docker: How to live sync host folder with container folder?

You can use volumes in order to do this. You have two options:

  1. Docker managed volumes:

    docker run -v /src/path nodejsapp
    docker run -i -t -volumes-from <container id> bash
    

The file you edit in the second container will update the first one.

  1. Host directory volume:

    docker run -v `pwd`/host/src/path:/container/src/path nodejsapp
    

The changes you make on the host will update the container.

Leave a Comment