一个docker镜像中的目录删除不了问题
在一个容器中,删除一个目录,失败:
bash-4.2# pwd
/home/zxcdn/ottcache/tomcat
bash-4.2# uname -a
Linux 3516b6c97679 3.10.-327.22..el7.x86_64 # SMP Fri Sep :: CST x86_64 x86_64 x86_64 GNU/Linux
bash-4.2# whoami
root bash-4.2# ls -alrt bin
total
drwxr-xr-x. root root Dec : .
drwxr-xr-x. root root Dec : .. bash-4.2# rm -rf bin
bash-4.2# ls -i
bin
bash-4.2# rm -rf bin
bash-4.2# ls -i
bin
相关docker版本信息:
[root@host---- caq]# docker info
Containers:
Running:
Paused:
Stopped:
Images:
Server Version: 1.13.
Storage Driver: overlay2----------存储引擎
Backing Filesystem: extfs--------底层文件系统
Supports d_type: true
Native Overlay Diff: false
Logging Driver: journald
Cgroup Driver: systemd
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: /usr/libexec/docker/docker-init-current
containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: 5eda6f6fd0c2884c2c8e78a6e7119e8d0ecedb77 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
seccomp
WARNING: You're not using the default seccomp profile
Profile: /etc/docker/seccomp.json
Kernel Version: 3.10.-327.22..el7.x86_64
Operating System: Carrier Grade Server Linux
OSType: linux
Architecture: x86_64
Number of Docker Hooks:
CPUs:
Total Memory: 3.703 GiB
Name: host----
ID: 4CV6:Y3Q4:NYGV:PABH:VG42:3CN7:CKET:SEIV:4SYF:63PI:HYAB:AZR2
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Experimental: false
Insecure Registries:
0.0.0.0/
127.0.0.0/
Live Restore Enabled: false
Registries: docker.io (secure)
发现删除不了这个空目录,strace跟踪一下,报错如下:
fcntl(, F_GETFL) = 0x38800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_NOFOLLOW)
fcntl(, F_SETFD, FD_CLOEXEC) =
getdents(, /* 2 entries */, ) =
getdents(, /* 0 entries */, ) =
close() =
unlinkat(AT_FDCWD, "bin", AT_REMOVEDIR) = - EINVAL (Invalid argument)
lseek(, , SEEK_CUR) = - ESPIPE (Illegal seek)
原来是unlinkat报错,然后内核打点跟踪,堆栈如下:
Returning from: 0xffffffff811ed500 : vfs_rename+0x0/0x790 [kernel]
Returning to : 0xffffffffa039860b : ovl_do_rename+0x3b/0xa0 [overlay]
0xffffffffa0398e4e : ovl_clear_empty+0x27e/0x2e0 [overlay]
0xffffffffa0398f28 : ovl_check_empty_and_clear+0x78/0x90 [overlay]
0xffffffffa039999c : ovl_do_remove+0x1ec/0x470 [overlay]
0xffffffffa0399c36 : ovl_rmdir+0x16/0x20 [overlay]
0xffffffff811ec738 : vfs_rmdir+0xa8/0x100 [kernel]
0xffffffff811f16d5 : do_rmdir+0x1a5/0x200 [kernel]
0xffffffff811f28b5 : SyS_unlinkat+0x25/0x40 [kernel]
0xffffffff81649909 : system_call_fastpath+0x16/0x1b [kernel]
看下确定是vfs_rename出错了,具体按行号打点:
probe kernel.statement("vfs_rename@namei.c:4122")
{
p_my=@cast($old_dir,"struct inode")->i_op;
iflags=@cast($old_dir,"struct inode")->i_flags;
printf("line 4122 flags=%u,rename2=%x,iflags=%u\r\n",$flags,@cast(p_my,"struct inode_operations_wrapper")->rename2,iflags);
print_backtrace();
}
对应的内核源码:
int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
struct inode **delegated_inode, unsigned int flags)
{
。。。。
rename2 = get_rename2_iop(old_dir);---------------4118行
if (!old_dir->i_op->rename && !rename2)
return -EPERM; if (flags && !rename2)----------------------------4122行
return -EINVAL;
。。。。
}
一开始我直接取的rename2,发现不为NULL,按道理进不去4122行,后来经细心的谈虎走查,才发现是进入了如下的判断条件:
static inline const struct inode_operations_wrapper *get_iop_wrapper(struct inode *inode,
unsigned version)
{
const struct inode_operations_wrapper *wrapper; if (!IS_IOPS_WRAPPER(inode))------------最终是这个条件起作用了
return NULL;
wrapper = container_of(inode->i_op, const struct inode_operations_wrapper, ops);
if (wrapper->version < version)
return NULL;
return wrapper;
} static inline iop_rename2_t get_rename2_iop(struct inode *inode)
{
const struct inode_operations_wrapper *wrapper = get_iop_wrapper(inode, );
return wrapper ? wrapper->rename2 : NULL;
}
看起来,该内核版本的overlay存储引擎,对ext3的底层文件系统,兼容性存在一些问题。后来使用device-mapper来解决了该问题。
ext4里面,ext4_iget的时候,对目录操作的时候,inode的i_flags是设置了S_IOPS_WRAPPER属性的,
} else if (S_ISDIR(inode->i_mode)) {
inode->i_op = &ext4_dir_inode_operations.ops;
inode->i_fop = &ext4_dir_operations;
inode->i_flags |= S_IOPS_WRAPPER;
但是ext3没有设置。
一个docker镜像中的目录删除不了问题的更多相关文章
- 在docker镜像中加入环境变量
原文链接 前言 reference:https://vsupalov.com/docker-build-time-env-values/ 很多时候,我们需要在docker镜像中加入环境变量,本人了解的 ...
- 给Ocelot做一个Docker 镜像
写在前面 在微服务架构中,ApiGateway起到了承前启后,不仅可以根据客户端进行分类,也可以根据功能业务进行分类,而且对于服务调用服务也起到了很好的接口作用.目前在各个云端中,基本上都提供了Api ...
- Docker镜像的获取与删除
Docker运行容器前需要本地存在对应的镜像,如果镜像不存在本地,Docker会尝试先从默认镜像仓库下载(默认使用Dicker Hub公共注册服务器中的仓库),用户也可以通过配置,使用自定义的镜像仓库 ...
- Docker镜像中的base镜像理解
base 镜像有两层含义: 不依赖其他镜像,从 scratch 构建. 其他镜像可以之为基础进行扩展. 所以,能称作 base 镜像的通常都是各种 Linux 发行版的 Docker 镜像,比如 Ub ...
- springboot程序构建一个docker镜像(十一)
准备工作 环境: linux环境或mac,不要用windows jdk 8 maven 3.0 docker 对docker一无所知的看docker教程. 创建一个springboot工程 引入web ...
- (转)Docker镜像中的base镜像理解
base 镜像有两层含义: 不依赖其他镜像,从 scratch 构建. 其他镜像可以之为基础进行扩展. 所以,能称作 base 镜像的通常都是各种 Linux 发行版的 Docker 镜像,比如 Ub ...
- Spring Boot教程(十一) springboot程序构建一个docker镜像
准备工作 环境: linux环境或mac,不要用windows jdk 8 maven 3.0 docker 对docker一无所知的看docker教程. 创建一个springboot工程 引入web ...
- docker镜像中文件丢失
背景介绍 笔者创建了一个镜像,然后在不同的主机上启动,发现有的能启动,有的却不行,报错信息为找不到文件. 犹记得当初有人介绍,只要docker镜像做好了,拿到任何地方都可以用,此处好像不成呢,好诡异的 ...
- 向docker镜像中传递变量的两种方式
测试用到的python文件: #!/usr/bin/env python3 #conding: utf-8 from http.server import HTTPServer, BaseHTTPRe ...
随机推荐
- java中原生的发送http请求(无任何的jar包导入)
package com.teamsun.pay.wxpay.util; import java.io.BufferedReader; import java.io.IOException; impor ...
- POJ 多项式加法
题解: 采用顺序表.考虑到题目中没有规定指数上界,为避免RE,拟不采用数组.参考了http://blog.csdn.net/inlovecy/article/details/15208473后,最终采 ...
- Spark操作实战
1. local模式 $SPARK_HOME/bin/spark-shell --master local import org.apache.log4j.{Level,Logger} // 导入ja ...
- mybatis的插件,挺好支持下
利用 Mybatis-generator自动生成代码http://www.cnblogs.com/yjmyzz/p/4210554.html Mybatis 通用 Mapper3 https://gi ...
- centos7 安装后静态ip的配置
centos7 想到于centos6.5来说界面上看起来更加炫一点,但是在配置静态ip上来说是差不多的 首先看一下centos7的安装界面,相对来说简洁好看一些 先打开终端 可以看到centos7默认 ...
- 使用nginx secure_link指令实现下载防盗链
一.安装nginx并检查是否已安装模块 [root@img_server ~]# nginx -V #输出nginx所有已安装模块,检查是否有ngx_http_secure_link_module 二 ...
- MongoDB Shell 常用操作命令
MonoDB shell命令操作语法和JavaScript很类似,其实控制台底层的查询语句都是用javascript脚本完成操作的. Ø 数据库 1.Help查看命令提示 help db.help ...
- [Lua]内存泄漏与垃圾回收
参考链接: http://colen.iteye.com/blog/578146 一.内存泄漏的检测 Lua的垃圾回收是自动进行的,但是我们可以collectgarbage方法进行手动回收.colle ...
- Java课程作业之动手动脑(五)
1.请阅读并运行AboutException.java示例. import javax.swing.*; class AboutException { public static void main( ...
- linux环境下Mysql的卸载和重新安装和启动
MySql安装 1 安装包准备 1.查看mysql是否安装,如果安装了,卸载mysql (1)查看 [root@hadoop102 桌面]# rpm -qa|grep mysqlmysql-libs- ...