How to check from within docker for an open file on a mounted dockerhost filesystem/volume

830 views Asked by At

My app, running within its own docker container, needs to check if a file located on a mounted filesystem/volume is still open by another process on the linux dockerhost (not a process within the container of this app). E.g. my app should only start processing an input file AFTER a process on the dockerhost finished writing this file.

If my app would be running directly on the dockerhost, a "fuser" or "lsof" command (run as root/via sudo) would provide the needed output (e.g. to list process ids that access the file). But from within the docker container the fuser command (even run as root) does not show any processes.

Any code snippet either on unix level or even better python3 would be helpful!

1

There are 1 answers

0
Heiko Gruner On

My personal workaround/solution is to connect from within docker to the dockerhost via ssh, run the fuser command remotely on the dockerhost and check the output within docker ...