docker容器中使用chattr修改文件权限报错 "chattr: Operation not permitted while setting flags on ***"

docker中默认是禁止 CAP_LINUX_IMMUTABLE
像chattr这些命令,是无法正常使用的,
如果使用 chattr +i file 会提示
chattr: Operation not permitted while setting flags on ***
要正常使用chattr等命令, 需要开启 CAP_LINUX_IMMUTABLE

docker run -it --cap-add LINUX_IMMUTABLE xxx

如果提示没有chattr命令,需要安装e2fsprogs

yum -y install e2fsprogs