在泊坞窗外保存的文件作为docker卷被损坏
在我的主人,我有这个目录:
/Users/gezimhome/projects/ziprecipes.net/zip-recipes/src
我将其装载到我的docker容器中,如下所示:
/usr/share/nginx/html/wordpress/wp-content/plugins/zip-recipes
如果我修改以下文件(例如添加一个新行)docker: /Users/gezimhome/projects/ziprecipes.net/zip-recipes/src/plugins/VisitorRating/scripts/main.js
,我得到一个语法错误浏览器:
苹果浏览器:
铬:
如果我进入docker集装箱,打开文件( /usr/share/nginx/html/wordpress/wp-content/plugins/zip-recipes/plugins/VisitorRating/scripts/main.js
)并再次保存没有改变,错误消失了。
我知道这将是一个弯曲的头脑。
我已经尝试了多个编辑器/ IDE在我的主机保存文件。 没什么区别。
更新 :哇,我保存在docker里面的文件,当我从docker里面编辑它,当我从外面编辑它,并做了差异没有发现差异:
cp /usr/share/nginx/html/wordpress/wp-content/plugins/zip-recipes/plugins/VisitorRating/scripts/main.js /host.js # editted the file in same way inside docker cp /usr/share/nginx/html/wordpress/wp-content/plugins/zip-recipes/plugins/VisitorRating/scripts/main.js /docker.js root@219a4126d14a:/# diff /host.js /docker.js root@219a4126d14a:/#
原来这是由nginx中的sendfile
设置引起的。
为了解决这个问题,我改变了我的nginx网站configuration文件(在我的情况下是/etc/nginx/sites-enabled/nginx_wordpress
),设置sendfile off
如下:
server { listen 8080; server_name zrdn; sendfile off; ... }