Dockerfile "rm -Rf" does not work

I have a very simple dockerfile with "rm -Rf" to delete installation files after installation, but I got some error, for example:

  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

I run everything with root user.

My docker file:

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

My OS is centos7 and the host OS is RHLE 7.

Docker info

  [ 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

I also tried a new container and tried it manually, but the result also is an error:

  [ 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

You can see that the second rm fails, I tried rmdir, resule is also an error.

While I'm in the directory, it shows:

  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

You can say that there is no such file, but follow the files.

+5
source share
3 answers

I had the same problem after spending several hours to find this problem: https://github.com/docker/docker/issues/27358

In short, this is how I fixed it.

When you do the docker information, you have Storage Driver: overlay in your output, I had the same thing as I did, this is changing the overlay to devicemapper. Follow the instructions given here - https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/#configure-docker-with-the-devicemapper-storage-driver

You will also need to stop and start the docker service.

Note: After the change, you will lose all your previous images, which means you will not see any images / containers when entering docker images or docker ps . They will be in the file system, they will occupy disk space. Therefore, you will have to manually delete this directory, so it will be under /var/lib/docker/overlay .

+1
source

It's your problem:

 Supports d_type: false 

You probably came across this: https://github.com/moby/moby/issues/31283

You will need to reformat the xfs file system, for example:

 mkfs -t xfs -n ftype=1 -f /path/to/device 

(we need a power parameter somehow).

Additional information: https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/7.2_Release_Notes/technology-preview-file_systems.html

0
source

I believe this is a problem with docker.

As a workaround, you can try the following:

 RUN rm -Rf /INSTALLATION/* 
-2
source

Source: https://habr.com/ru/post/1264117/


All Articles