Docker在构build图像时无法删除文件
我的DockerFile包含以下指令:
rm -f plugins.7z
这个命令在Docker的早期版本中按预期工作,但是在版本1.13中失败。 我看到错误:
cannot access plugins.7z: No such file or directory
如果我调出一个带有基本映像的容器并手动执行命令,我看到同样的错误。
试图列出文件夹内容显示:
# ls -lrt ls: cannot access plugins.7z: No such file or directory total 12 ??????????? ? ? ? ? ? plugins.7z
这不是Docker问题中已知的问题 。 如何进一步debugging问题?
编辑:
- 由于IP的原因,我不能在这里发布完整的Dockerfile。 另外,可能没有必要。 正如我所提到的,我甚至可以通过手动运行容器并尝试执行命令来模拟问题
- 我试图删除它之前,该文件存在
- 我错了问题列表中没有类似的错误。 这是一个
- 这个问题可能与该文件无关。 删除文件夹中的其他文件/文件夹也使得它们出现? 权限
- 执行操作的用户是root用户
删除目录失败的原因是,支持( xfs
)文件系统没有使用d_type支持(“ftype = 1”)格式化; 你可以在github上find一个讨论; https://github.com/docker/docker/issues/27358 。
要validation您的系统是否支持d_type
支持,请检查d_type
docker info
的输出;
Server Version: 1.13.1 Storage Driver: overlay Backing Filesystem: xfs Supports d_type: false Logging Driver: json-file
RHEL / CentOS发行说明中也描述了这一要求
请注意,XFS文件系统必须使用
-n ftype=1
选项创build,才能用作叠加层。 使用系统安装期间创build的rootfs和任何文件系统,在Anaconda kickstart中设置--mkfsoptions=-n ftype=1
参数。 安装后创build新的文件系统时,运行# mkfs -t xfs -n ftype=1 /PATH/TO/DEVICE
命令。 要确定现有的文件系统是否可以用作覆盖,请运行# xfs_info /PATH/TO/DEVICE | grep ftype
# xfs_info /PATH/TO/DEVICE | grep ftype
命令查看是否启用了ftype=1
选项。
要解决这个问题,要么;
- 用
ftype=1
重新格式化设备 - 使用不同的存储驱动程序。 请注意,默认设备映射程序configuration(使用回送设备)不build议用于生产使用,因此需要手动configuration。
为了向后兼容( d_type
旧版本允许在没有d_type
系统上运行覆盖), d_type
1.13将只在守护进程日志( https://github.com/docker/docker/pull/27433 )中logging警告 ,但是不会未来的版本将会得到支持。
能够克服这个问题。
1.13的更改日志说
"IMPORTANT: On Linux distributions where devicemapper was the default storage driver, the overlay2, or overlay is now used by default (if the kernel supports it)."
所以我试着把devicemapper放回去,现在按预期工作。