merofeev / docker-windows-volume-watcher

A tool to notify Docker contianers about changes in mounts on Windows.
MIT License
188 stars 30 forks source link

WARNING:root:Bind of container was skipped since it has invalid source path #19

Open AntoineWeber opened 3 years ago

AntoineWeber commented 3 years ago

Hello,

One of my docker container requires access to a directory where it tracks file changes within that directory (using the watchdog library).

I tried using docker-windows-volume-watcher to maintain the watchdog alerts within the docker container, however when I launch it, I get the error "WARNING:root:Bind of container was skipped since it has invalid source path" where the path itself is a standard windows path : C:\path\to\the\directory_containing_the_files

Am I missing something here ?

mikekberg commented 3 years ago

I'm getting the same error, could it be problems with path? My path has a directory with a '-' in it

AntoineWeber commented 3 years ago

I rolled back my docker desktop version to 2.1.0.5 and it works. Hence I think the problem comes from an uncompatibility with the docker desktop version.

masquevil commented 3 years ago

same question 👀

masquevil commented 3 years ago

I open a PR: https://github.com/merofeev/docker-windows-volume-watcher/pull/21 But I'm not familiar with python and don't know how to build this on my local PC. So actually I have not verify this. Could anyone verify this or tell me what to do?

tp86 commented 3 years ago

I have the same issue

bensoutendijk commented 3 years ago

https://github.com/merofeev/docker-windows-volume-watcher/blob/41d3d29f8bf731117d0e49cad73345cc8af02a22/docker_volume_watcher/container_monitor.py#L27

I'm not experienced in python or docker, but I see that the paths are tested using regex which searches for "host_mnt" directory.

All my docker mounts are at a path like /mnt/c/Users/... which the below regex does not match.

re.compile('^(?:/host_mnt)?/([a-zA-Z])/(.*)$')

Maybe the Docker update changed the paths where containers are mounted, and so that is why downgrading Docker is a supposed workaround?

Seems like an easy fix to change this regex to ^(?:/host_mnt|/mnt)?/([a-zA-Z])/(.*)$ and support paths that begin with just /mnt.

rizktouma commented 3 years ago

@bensoutendijk I am facing the same issue now. I cloned the repository and changed the regex. How did you build the exe after you made the changes? I tried Pyinstaller but the generated exe is exiting right after I launch it and I am no longer getting any log messages.

bensoutendijk commented 3 years ago

@rizktouma Sorry but I never did end up getting this to work, so I am not sure I can help you. I didn't get to the build step.

GeorgesAlexis commented 2 years ago

@rizktouma

You could change the python script directly where pip has installed this package.

pip3 show docker-windows-volume-watcher

Output :

$ pip3 show docker-windows-volume-watcher Name: docker-windows-volume-watcher Version: 1.2.0 Summary: A tool to notify Docker contianers about changes in mounts on Windows. Home-page: http://github.com/merofeev/docker-windows-volume-watcher Author: Mikhail Erofeev Author-email: mikhail@erofeev.pw License: MIT Location: c:\users\alexis\appdata\local\programs\python\python310\lib\site-packages Requires: docker, future, watchdog Required-by:

Go at the location and edit your files:

LINE 27: expr = re.compile('^(?:/mnt)?/([a-zA-Z])/(.*)$')

laggingreflex commented 2 years ago

The function (in which the above line 27 is) says:

def docker_bind_to_windows_path(path):
    """
    Converts Hyper-V mount path to Windows path (e.g. [/host_mnt]/C/some-path -> C:/some-path).
    """
    expr = re.compile('^(?:/host_mnt)?/([a-zA-Z])/(.*)$')

but in my case path is already C:\some-path (no /host_mnt or /mnt or even /C/ to begin with). So making it redundant (retuning path as-is) is what makes it work in my case.

EDIT: No longer working for some reason (I haven't made any major changes to the system - just some Windows Updates). The path above has changed to /run/desktop/mnt/host/… so replacing host_mnt with it is what works now.

KingofGnome commented 2 years ago

Searching for a solution for the skipped since it has invalid source path i found this issue (like after banging my had around a --reload not working-problem for hours nefore finding the docker-windows-volume-watcher after all).

Sadly none of the above fixes did anything for me. However manipulating the problematic def docker_bind_to_windows_path(path):-Function i've noticed my 'problematic' path 'C:/Users:/...' looks already like the desired outcome of the function?!

So i dumped in a return path to see what happend and...it works (for me). I don't know whats wrong with the functions, the mountpath and regex-matching, but for me, putting in a

def docker_bind_to_windows_path(path):
    if path.starthwith('C:'):
        return path

does the job for now. Ofc. having only a C-Drive on my Laptop 😉.

Maybe it will help someone, its not a fix in any ways, just another workaround.