5

Is there an easy way to track file changes (files will be changed elsewhere) inside the docker container. I used COPY within the Dockerfile to test the functionality but now I need to keep track if the copied files are changing in the background. The changes are made within a different application (Not a docker container). This app fetches data and overwrites those files if something has changed --> Then my container should react to the changes and synchronize it's files.

Is a simple MOUNT enough to establish that?

Regards

  • 1
    I think you have to mount the directory, where the changes to the files were made, into the Docker-Image. Do you know how to do that? COPY-Command is only for copying a file into a Docker-Image, but when changes are made to these File(s), the Container or Image doesnt knows about that. – adbo Jan 18 '18 at 09:42
  • You have to use a volume (-v /path/on/host:/path/in/container) – papey Jan 18 '18 at 10:21
  • After a quick read of [Manage data in Docker](https://docs.docker.com/engine/admin/volumes/), I think you have 2 options: either [volumes](https://docs.docker.com/engine/admin/volumes/volumes/) or [bind mounts](https://docs.docker.com/engine/admin/volumes/bind-mounts/). I have also found this: [Monitoring file changes in Docker volumes](https://stackoverflow.com/questions/30457778/monitoring-file-changes-in-docker-volumes) which might help you but I don't know if it is the best practice. – tgogos Jan 18 '18 at 10:22

1 Answers1

3

Check

inotify docker image https://github.com/pstauffer/docker-inotify

or

https://hub.docker.com/r/coppit/inotify-command/

or

https://hub.docker.com/r/coppit/inotify-command/~/dockerfile/

user2915097
  • 30,758
  • 6
  • 57
  • 59