GithubHelp home page GithubHelp logo

georgesalexis / docker-windows-volume-watcher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from merofeev/docker-windows-volume-watcher

0.0 0.0 0.0 31 KB

A tool to notify Docker contianers about changes in mounts on Windows.

License: MIT License

Python 100.00%

docker-windows-volume-watcher's Introduction

Docker Windows Volume Watcher

This script monitors directory bindings of Docker containers on Windows hosts and notifies containers about file changes.

The script aims to be workaround for the problem of file change events propagation on Windows hosts. Due to limitations of CIFS implementation in Linux kernel, file change events in mounted folders of host are not propagated to container by Docker for Windows. This problem renders watch mode of modern frameworks (e.g. Jekyll, ng-cli, etc.) development servers useless, since containers are not notified about file changes. This problem is described on Docker Community Forums.

Installation

This script can be installed with pip (both Python 2 & 3 are supported).

pip install docker-windows-volume-watcher

Usage

Monitor all directory bindings of all containers. The script will listen for container start/stop events and notify all running containers about file changes.

docker-volume-watcher

Monitor only bindings of container container_name.

docker-volume-watcher container_name

Monitor only binding of container_name to host directory C:\some\directory.

docker-volume-watcher container_name C:\some\directory

You can also specify wildcards with * and ? characters. For example: monitor only bindings of containers with names containing myproject to directories starting with C:\project\folder\.

docker-volume-watcher *myproject* C:\project\folder\*

Do not monitor files/directories matching *.git* and *build* patterns:

docker-volume-watcher -e "*.git*" "*build*"

If you experience duplicate notification issue (e.g. Duplicate notification - a single change triggers 2 notifications to the container), try event debounce feature:

docker-volume-watcher --debounce 0.1

Use flag -v to enable verbose output: the script will report start/stop events of eligible containers and print all detected file changes.

Limitations

  • The script doesn't propagate to container file deletion events.
  • The script requires stat and chmod utils to be installed in container (this should be true by default for the most of containers).

Implementation details

The script uses watchdog package to observe file change events of the host directory. Once file change event is fired the script reads file permissions of changed file (using stat util) and rewrites file permissions with the same value (using chmod util) thus triggering inotify event inside container.

"Rewrite file permissions approach" was used instead of updating file last modified time with touch util. Since touching will cause event loop: touch will trigger file change event in Windows, script will handle this event and touch file again, etc.

docker-windows-volume-watcher's People

Contributors

arnezsng avatar etrepum avatar merofeev avatar rolandmay avatar toilal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.