[英]File mounted as docker volume becomes corrupt when saved outside docker
在主机中,我有这个目录:
/Users/gezimhome/projects/ziprecipes.net/zip-recipes/src
我将其安装到我的docker容器上的方式是:
/usr/share/nginx/html/wordpress/wp-content/plugins/zip-recipes
如果我在/Users/gezimhome/projects/ziprecipes.net/zip-recipes/src/plugins/VisitorRating/scripts/main.js
外部修改以下文件(例如,添加新行):/ /Users/gezimhome/projects/ziprecipes.net/zip-recipes/src/plugins/VisitorRating/scripts/main.js
, /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
),然后再次保存没有更改,错误就消失了。
我知道这将是一个弯腰。
我已经尝试在主机中使用多个Editors / 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网站配置文件(在我的情况下为/etc/nginx/sites-enabled/nginx_wordpress
)以将sendfile off
设置为sendfile off
,如下所示:
server {
listen 8080;
server_name zrdn;
sendfile off;
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.