watcher

package module
v0.0.0-...-5f1ea5a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2018 License: MIT Imports: 19 Imported by: 0

README

docker-windows-volume-watcher

A simple command line utility to get autobuild working inside containers running on Docker for Windows with mounting host (= Windows) directories to containers.

This is a workaround for Inotify on shared drives does not work · Issue #56 · docker/for-win.

Inspired by Mikhail Erofeev's Python tool and Frode Hus's Go tool.

Usage

Run the command docker-windows-volume-watcher on any directory you like.

Pass semicolon separated directories that you want to ignore to -ignoredir option.

You can specify relative directories like below, in this case the directoies are converted to the absolute path with a mount source directory as the base directory.

docker-windows-volume-watcher -ignoredir .git;build\html

Also you can specifiy absolute directories like -ignoredir C:\path\to\ignore. And you can mix relative and absolute directories ignoredir .git;build\html;C:\path\to\ignore.

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

This command uses a Go client for the Docker Engine API to observe container lifecycle events.

It also uses fsnotify/fsnotify: Cross-platform file system notifications for Go. 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Watch

func Watch(ctx context.Context, apiVersion string, ignoreDirs []string) error

Watch watches changes of host files and notify the change to the container.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL