Docker的Native Overlay Diff选项相关随记
来自三线的随记
核心原因是因为overlay module 在load的时候参数值的差异
- 与overlay模块参数redirect_dir有关
- redirect_dir 参数值为off 的时候, Native Overlay Diff为true
- 此参数会对docker build带来性能等差异
当native overlay diff 为false带来的影响
(注意此下结论为引用自他人结论,未经我实际测试)
如果返回是 False。意味这 kernel 不会处理 Diff,而是通过“上层”的方法处理,性能很低。另外可能会有bug,这些问题可以通过 docker 的日志看到。
具体bug可以参考 https://github.com/moby/moby/blob/ed07e1152879a4d156dff2e86abca3c4c811e743/daemon/graphdriver/overlay2/check.go
doesSupportNativeDiff checks whether the filesystem has a bug which copies up the opaque flag when copying up an opaque directory or the kernel enable CONFIG_OVERLAY_FS_REDIRECT_DIR.When these exist naive diff should be used.
Not using native diff for overlay2, this may cause degraded performance for building images
处理
/sys/module/$module/parameters/$parameter
[root@dce-192-168-150-113 ~]# ls /sys/module/overlay/parameters/ check_copy_up index nfs_export redirect_always_follow redirect_dir redirect_max xino_auto [root@dce-192-168-150-113 ~]# cat /sys/module/overlay/parameters/redirect_dir N
script: dump all loaded module parameter values
#/bin/env bash cat /proc/modules | cut -f 1 -d " " | while read module; do \ echo "Module: $module"; \ if [ -d "/sys/module/$module/parameters" ]; then \ ls /sys/module/$module/parameters/ | while read parameter; do \ echo -n "Parameter: $parameter --> "; \ cat /sys/module/$module/parameters/$parameter; \ done; \ fi; \ echo; \ done
解决方法/ workaround
echo 'options overlay redirect_always_follow=off redirect_dir=off' > /etc/modprobe.d/disable_overlay_redirect_dir.conf