Centos系统docker的坑

环境:CentOS Linux release 7.1.1503 (Core)
dockerfiles 中有

1
2
3
RUN mv /app/docker/localtime /etc/localtime
......
RUM rm /app/docker

docker build 过程中发现报错

1
2
mv: can't rename '/app/docker/localtime': Invalid argument
The command '/bin/sh -c mv /app/docker/localtime /etc/localtime' returned a non-zero code: 1

而同样的脚本在另外一个Ubuntu系统下没有这样的报错
从 docker info中可以看到
不正常系统
Centos7
正常系统
Ubuntu16.04
并且可以看到报错信息

1
2
3
WARNING: overlay: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior.
Reformat the filesystem with ftype=1 to enable d_type support.
Running without d_type support will not be supported in future releases.

Centos7 发行版默认的Kernel版本是3.10,但是Overlay2存储驱动需要4.0以上的kernel版本支持,所以默认使用overlay 并且不支持d_type, 才导致这个报错。
具体
解决方法一:
格式化 XFS 系统,添加ftype=1

1
2
3
4
# 查看当前系统xfs
xfs_info /
如果 ftype =0 表示不支持d_type
省略具体格式化方法

解决方法二:
修改 storage driver 为 devicemapper

1
2
3
4
5
6
vim /etc/docker/daemon.json
增加
{
...
"storage-driver": "devicemapper"
}

docker疑难杂症
docker文件系统参考
github上的讨论