Dockerfile“rm -Rf”失败

前端之家收集整理的这篇文章主要介绍了Dockerfile“rm -Rf”失败前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一个非常简单的dockerfile,安装后用“rm -Rf”删除安装文件,但是我得到了一些错误

Step 4/4 : RUN rm -Rf /INSTALLATION
 ---> Running in 19fe828f3c9d
rm: cannot remove '/INSTALLATION/Subsystems/Common': Directory not empty
rm: cannot remove '/INSTALLATION/Subsystems/EMS': Directory not empty

我用root用户运行所有.

我的dockerfile:

FROM centos
COPY INSTALLATION/ /INSTALLATION/ 
RUN  rm -Rf /INSTALLATION

我的操作系统是centos7,主机操作系统是RHLE 7.

Docker信息

[root@snap460c03 1]# docker info
Containers: 53
 Running: 27
 Paused: 0
 Stopped: 26
Images: 19
Server Version: 1.13.0
Storage Driver: overlay
 Backing Filesystem: xfs
 Supports d_type: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 03e5862ec0d8d3b3f750e19fca3ee367e13c090e
runc version: 2f7393a47307a16f8cee44a37b262e8b81021e3e
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-229.el7.x86_64
Operating System: Red Hat Enterprise Linux Server 7.1 (Maipo)
OSType: linux
Architecture: x86_64
cpus: 24
Total Memory: 94.41 GiB
Name: snap460c03
ID: T3ST:6DXJ:SDST:3W3J:Z4NB:UXF7:HGSZ:A3WH:ELHX:GVZW:APTD:7ZEK
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Http Proxy: http://16.85.88.10:8080/
No Proxy: docker-registry
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 docker-registry:5000
 127.0.0.0/8
Live Restore Enabled: false

我也尝试了新的容器并手动尝试,但结果也是错误的:

[root@devvm13 1]# docker run -it e20c9c5ffa8a /bin/bash

[root@f3efa193700d /]# rm -Rf /INSTALLATION/Subsystems/Common/*

[root@f3efa193700d /]# rm -Rf /INSTALLATION/Subsystems/Common 

rm: cannot remove '/INSTALLATION/Subsystems/Common': Directory not empty

你可以看到第二个rm失败,我试过rmdir,resule也是错误的.

当我在目录中时,它显示

ls /INSTALLATION/Subsystems/Common
ls: cannot access /INSTALLATION/Subsystems/Common/eium-license.config: No such file or directory
ls: cannot access /INSTALLATION/Subsystems/Common/install_jdk.sh: No such file or directory
eium-license.config  install_jdk.sh

你可以说没有这样的文件,但跟着文件.

最佳答案
在花了几个小时发现这个问题之后,我遇到了同样的问题: –
https://github.com/docker/docker/issues/27358

所以长话短说,这就是我修复它的方法.

当您执行docker信息时,在输出中您有存储驱动程序:overlay,我有相同的,我所做的是将overlay更改为devicemapper.按照此处显示的说明进行操作 – https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/#configure-docker-with-the-devicemapper-storage-driver

您还必须停止并启动docker服务.

注意 :
更改后,您将丢失所有过去的图像,这意味着当您键入docker图像或docker ps时,您将看不到任何图像/容器.他们将在fileSystem中,他们将占用磁盘空间.因此,您必须手动删除该目录,因此它将位于/ var / lib / docker / overlay下.

猜你在找的Docker相关文章