Docker Community Forums

Share and learn in the Docker community.

Auto-synch data in container upon changes in host

docker

(Galioy) #1

Is it possible to have a volume that is sort of “live synched” between the host and the container? My point is to have a Node.js app/project on the host machine, and then run a node.js container, which will pick up the project and then whenever I change a file in the project - it to get immediately updated in the container without having to restart the container in order for the volume to get copied.

Currently I have the source code copied in the container’s volume upon lifting the container:

server:
    build: .
    ports:
      - "8001:1337"
    volumes:
      - ./app:/app
    command: npm start

but, as you can see, I need to restart the container every time I want the changes to be updated from the host to the container.

If that is possible, could you provide an example how to write it in docker-compose and maybe also a link to the appropriate docs?