小编OSU*_*ian的帖子

docker 安装卷上的 inotify (Mac / Linux)

我已经搜索了几个小时,似乎找不到该问题的最新答案

问题:显然 VirtualBox 正在 MacOS 上由 Docker 使用,并且它不希望将文件通知从主机操作系统传递到容器。因此,当从容器内执行这些操作时,inotifywait 只会通知监视文件夹上的文件活动。当这些操作是从主机执行时则不会。

Dockerfile

FROM python:3.9.6
COPY main.sh /bin/main.sh
RUN chmod +x /bin/main.sh
RUN apt-get update -y
RUN apt-get install -y inotify-tools
CMD /bin/main.sh
Run Code Online (Sandbox Code Playgroud)

主目录

#!/usr/bin/env bash

inotifywait -mq -r -e create -e modify -e delete -e move /data |
    while read path action file; do
        echo "The file '$file' appeared in directory '$path' via '$action'" >> log.txt
    done
Run Code Online (Sandbox Code Playgroud)

构建容器

docker build -f Dockerfile -t my_container .
Run Code Online (Sandbox Code Playgroud)

运行容器

docker run -it -v …
Run Code Online (Sandbox Code Playgroud)

inotify inotifywait docker docker-for-mac

6
推荐指数
1
解决办法
5594
查看次数

标签 统计

docker ×1

docker-for-mac ×1

inotify ×1

inotifywait ×1