2017-10-19 69 views
1

时,问题类似于Docker is unable to delete a file when building images码头工人无法建立图像

删除目录然而,路线的原因是不一样的,因为d_type在我的情况下启用。

这里是Dockerfile

FROM arm64v8/ubuntu:latest 

RUN export DEBIAN_FRONTEND='noninteractive' && \ 
    rm -rf /var/lib/apt/lists/* /tmp/* /usr/share/doc 

当试图建立图像

docker build -t arm64v8-ubuntu-test . 

我收到以下错误

Sending build context to Docker daemon 3.584kB 
Step 1/2 : FROM arm64v8/ubuntu:latest 
---> 499b06aa549b 
Step 2/2 : RUN export DEBIAN_FRONTEND='noninteractive' &&  rm -rf /var/lib/apt/lists/* /tmp/* /usr/share/doc 
---> Running in 5ff328ef5a57 
rm: cannot remove '/usr/share/doc/sed': Directory not empty 
rm: cannot remove '/usr/share/doc/libpam-modules': Directory not empty 
rm: cannot remove '/usr/share/doc/util-linux': Directory not empty 
rm: cannot remove '/usr/share/doc/mawk': Directory not empty 
rm: cannot remove '/usr/share/doc/gnupg': Directory not empty 
rm: cannot remove '/usr/share/doc/apt': Directory not empty 
rm: cannot remove '/usr/share/doc/libreadline6': Directory not empty 
rm: cannot remove '/usr/share/doc/adduser/examples/adduser.local.conf.examples': Directory not empty 
rm: cannot remove '/usr/share/doc/passwd': Directory not empty 
rm: cannot remove '/usr/share/doc/mount': Directory not empty 
rm: cannot remove '/usr/share/doc/procps': Directory not empty 
The command '/bin/sh -c export DEBIAN_FRONTEND='noninteractive' &&  rm -rf /var/lib/apt/lists/* /tmp/* /usr/share/doc' returned a non-zero code: 1 

我泊坞窗信息是

$ docker info 
Containers: 7 
Running: 1 
Paused: 0 
Stopped: 6 
Images: 95 
Server Version: 17.10.0-ce 
Storage Driver: overlay 
Backing Filesystem: extfs 
Supports d_type: true 
Logging Driver: json-file 
Cgroup Driver: cgroupfs 
Plugins: 
Volume: local 
Network: bridge host macvlan null overlay 
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog 
Swarm: active 
NodeID: mjm8vu1ixmw1ls25dk7gomiva 
Is Manager: true 
ClusterID: lnspgxtrca8d4lm3kfv7zbz77 
Managers: 3 
Nodes: 3 
Orchestration: 
    Task History Retention Limit: 5 
Raft: 
    Snapshot Interval: 10000 
    Number of Old Snapshots to Retain: 0 
    Heartbeat Tick: 1 
    Election Tick: 3 
Dispatcher: 
    Heartbeat Period: 5 seconds 
CA Configuration: 
    Expiry Duration: 3 months 
    Force Rotate: 0 
Autolock Managers: false 
Root Rotation In Progress: false 
Node Address: 10.0.4.71 
Manager Addresses: 
    10.0.4.71:2377 
    10.0.4.72:2377 
    10.0.4.73:2377 
Runtimes: runc 
Default Runtime: runc 
Init Binary: docker-init 
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0 
runc version: 0351df1c5a66838d0c392b4ac4cf9450de844e2d 
init version: 949e6fa 
Security Options: 
seccomp 
    Profile: default 
Kernel Version: 3.14.79-27-ARCH 
Operating System: Arch Linux ARM 
OSType: linux 
Architecture: aarch64 
CPUs: 4 
Total Memory: 1.928GiB 
Name: alarm-docker-manager-host 
ID: Y5ZZ:5G3O:KIE2:MSQX:7MBB:XWOZ:CYLL:2SSY:GTMB:YCBG:4TTT:EJVN 
Docker Root Dir: /var/lib/docker 
Debug Mode (client): false 
Debug Mode (server): false 
Registry: https://index.docker.io/v1/ 
Experimental: false 
Insecure Registries: 
127.0.0.0/8 
Live Restore Enabled: false 

手动运行容器,并试图执行该命令具有相同的结果,例如

$ docker run --rm -it arm64v8/ubuntu:latest bash 
[email protected]:~# rm -rf /var/lib/apt/lists/* /tmp/* /usr/share/doc 
rm: cannot remove '/usr/share/doc/sed': Directory not empty 
rm: cannot remove '/usr/share/doc/libpam-modules': Directory not empty 
rm: cannot remove '/usr/share/doc/util-linux': Directory not empty 
rm: cannot remove '/usr/share/doc/mawk': Directory not empty 
rm: cannot remove '/usr/share/doc/gnupg': Directory not empty 
rm: cannot remove '/usr/share/doc/apt': Directory not empty 
rm: cannot remove '/usr/share/doc/libreadline6': Directory not empty 
rm: cannot remove '/usr/share/doc/adduser/examples/adduser.local.conf.examples': Directory not empty 
rm: cannot remove '/usr/share/doc/passwd': Directory not empty 
rm: cannot remove '/usr/share/doc/mount': Directory not empty 
rm: cannot remove '/usr/share/doc/procps': Directory not empty 

而且,权限似乎细,该目录是在那里,并且不被另一个过程

[email protected]:/# ls -lah/
total 68K 
drwxr-xr-x 1 root root 4.0K Oct 19 06:43 . 
drwxr-xr-x 1 root root 4.0K Oct 19 06:43 .. 
-rwxr-xr-x 1 root root 0 Oct 19 06:43 .dockerenv 
drwxr-xr-x 2 root root 4.0K Oct 19 05:39 bin 
drwxr-xr-x 2 root root 4.0K Apr 12 2016 boot 
drwxr-xr-x 5 root root 360 Oct 19 06:44 dev 
drwxr-xr-x 1 root root 4.0K Oct 19 06:43 etc 
drwxr-xr-x 2 root root 4.0K Apr 12 2016 home 
drwxr-xr-x 8 root root 4.0K Oct 19 05:39 lib 
drwxr-xr-x 2 root root 4.0K Oct 6 01:43 media 
drwxr-xr-x 2 root root 4.0K Oct 6 01:43 mnt 
drwxr-xr-x 2 root root 4.0K Oct 6 01:43 opt 
dr-xr-xr-x 143 root root 0 Oct 19 06:43 proc 
drwx------ 2 root root 4.0K Oct 19 05:39 root 
drwxr-xr-x 5 root root 4.0K Oct 6 01:44 run 
drwxr-xr-x 2 root root 4.0K Oct 19 05:39 sbin 
drwxr-xr-x 2 root root 4.0K Oct 6 01:43 srv 
dr-xr-xr-x 12 root root 0 Oct 19 06:43 sys 
drwxrwxrwt 2 root root 4.0K Oct 6 01:44 tmp 
drwxr-xr-x 10 root root 4.0K Oct 19 05:39 usr 
drwxr-xr-x 11 root root 4.0K Oct 19 05:39 var 

[email protected]:/# ls -lah /var/lib/apt 
total 24K 
drwxr-xr-x 6 root root 4.0K Oct 19 05:39 . 
drwxr-xr-x 11 root root 4.0K Oct 19 05:39 .. 
-rw-r--r-- 5 root root 0 Oct 6 01:44 extended_states 
drwxr-xr-x 2 root root 4.0K Oct 19 05:39 keyrings 
drwxr-xr-x 2 root root 4.0K Oct 11 14:01 lists 
drwxr-xr-x 3 root root 4.0K Oct 19 05:39 mirrors 
drwxr-xr-x 2 root root 4.0K Apr 14 2016 periodic 

[email protected]:/# ls -lah /usr/share 
total 160K 
drwxr-xr-x 40 root root 4.0K Oct 19 05:39 . 
drwxr-xr-x 10 root root 4.0K Oct 19 05:39 .. 
drwxr-xr-x 2 root root 4.0K Oct 19 05:39 adduser 
drwxr-xr-x 3 root root 4.0K Oct 19 05:39 apport 
drwxr-xr-x 2 root root 4.0K Oct 19 05:39 base-files 
drwxr-xr-x 2 root root 4.0K Oct 19 05:39 base-passwd 
drwxr-xr-x 3 root root 4.0K Oct 19 05:39 bash-completion 
drwxr-xr-x 6 root root 4.0K Oct 19 05:39 bug 
drwxr-xr-x 2 root root 4.0K Oct 19 05:39 common-licenses 
drwxr-xr-x 4 root root 4.0K Oct 19 05:39 dbus-1 
drwxr-xr-x 2 root root 4.0K Oct 19 05:39 debconf 
drwxr-xr-x 2 root root 4.0K Oct 19 05:39 debianutils 
drwxr-xr-x 2 root root 4.0K Apr 12 2016 dict 
drwxr-xr-x 94 root root 4.0K Oct 19 05:39 doc 
... 

[email protected]:/# lsof /usr/share/doc 
[email protected]:/# rm -rf /usr/share/doc 
rm: cannot remove '/usr/share/doc/sed': Directory not empty 
rm: cannot remove '/usr/share/doc/libpam-modules': Directory not empty 
rm: cannot remove '/usr/share/doc/util-linux': Directory not empty 
rm: cannot remove '/usr/share/doc/mawk': Directory not empty 
rm: cannot remove '/usr/share/doc/gnupg': Directory not empty 
rm: cannot remove '/usr/share/doc/apt': Directory not empty 
rm: cannot remove '/usr/share/doc/libreadline6': Directory not empty 
rm: cannot remove '/usr/share/doc/adduser/examples/adduser.local.conf.examples': Directory not empty 
rm: cannot remove '/usr/share/doc/passwd': Directory not empty 
rm: cannot remove '/usr/share/doc/mount': Directory not empty 
rm: cannot remove '/usr/share/doc/procps': Directory not empty 

RMDIR无法正常工作或

[email protected]:/# rmdir /usr/share/doc 
rmdir: failed to remove '/usr/share/doc': Directory not empty 
[email protected]:/# lsof /usr/share/doc 

同为直接运行rm命令

$ docker run --rm -it arm64v8/ubuntu:latest rm -rf /usr/share/doc 
rm: cannot remove '/usr/share/doc/sed': Directory not empty 
rm: cannot remove '/usr/share/doc/libpam-modules': Directory not empty 
rm: cannot remove '/usr/share/doc/util-linux': Directory not empty 
rm: cannot remove '/usr/share/doc/mawk': Directory not empty 
rm: cannot remove '/usr/share/doc/gnupg': Directory not empty 
rm: cannot remove '/usr/share/doc/apt': Directory not empty 
rm: cannot remove '/usr/share/doc/libreadline6': Directory not empty 
rm: cannot remove '/usr/share/doc/adduser/examples/adduser.local.conf.examples': Directory not empty 
rm: cannot remove '/usr/share/doc/passwd': Directory not empty 
rm: cannot remove '/usr/share/doc/mount': Directory not empty 
rm: cannot remove '/usr/share/doc/procps': Directory not empty 

而且使用sudo

$ sudo docker run --rm -it arm64v8/ubuntu:latest rm -rf /usr/share/doc 
rm: cannot remove '/usr/share/doc/sed': Directory not empty 
rm: cannot remove '/usr/share/doc/libpam-modules': Directory not empty 
rm: cannot remove '/usr/share/doc/util-linux': Directory not empty 
rm: cannot remove '/usr/share/doc/mawk': Directory not empty 
rm: cannot remove '/usr/share/doc/gnupg': Directory not empty 
rm: cannot remove '/usr/share/doc/apt': Directory not empty 
rm: cannot remove '/usr/share/doc/libreadline6': Directory not empty 
rm: cannot remove '/usr/share/doc/adduser/examples/adduser.local.conf.examples': Directory not empty 
rm: cannot remove '/usr/share/doc/passwd': Directory not empty 
rm: cannot remove '/usr/share/doc/mount': Directory not empty 
rm: cannot remove '/usr/share/doc/procps': Directory not empty 

这不是列为Docker Issues一个已知的问题。如何进一步调试该问题?

+0

你确定他们没有被使用吗?检查它是否有'lsof'。你用'rmdir'试过了吗? –

+0

我使用'lsof'进行了检查,并尝试使用'rmdir'。该目录未被使用。我更新了问题以包含这些额外的调试步骤。 –

+0

我试图用你的Dockerfile来构建一个容器,但是当运行'rm -rf'命令时我得到一个'exec format'错误 –

回答

0

在报告为Docker overlay storage driver unable to delete directories from underlying image layer #35257的问题之后,我深深地感谢thaJeztah。

https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/所述,覆盖存储驱动程序需要内核版本3.18或更高版本。

我的系统使用图像ArchLinuxARM-odroid-c2-latest.tar.gz,它具有较旧的内核版本3.14。

问题发生的原因是ALARM docker软件包默认配置了覆盖驱动程序,它只能在较新的内核版本(例如RPi映像或ODROID-C2的主线内核)上运行。

因此,解决方案是

  • 升级内核版本。我上次检查时,主线内核对ODROID-C2的支持有问题,所以下一个选项可能更可取。
  • 或者将docker配置为使用AUFS存储驱动程序而不是覆盖驱动程序。