moby: failed to remove root filesystem with overlay2: directory not empty

Description

I got the following error once on our CI server while deleting a container:

Error response from daemon: Driver overlay2 failed to remove root filesystem 45d8ebcb2398062054ea41c4b3b99f37857e16192471a61d438aa74cdf239933: remove /var/lib/docker/overlay2/40d30286027cbdec977922093f2b3eaafd59f5090af6edf38454604e1f663451-init/merged/media: directory not empty 

It happened randomly and I’ve never seen it before or since.

Steps to reproduce the issue: unknown; if anyone sees the same issue, please help find a repro

Describe the results you received: Engine error

Describe the results you expected: Successful container remove

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:      1.13.0-rc7
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   48a9e53
 Built:        Fri Jan 13 21:41:57 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.0-rc7
 API version:  1.25 (minimum version 1.12)
 Go version:   go1.7.3
 Git commit:   48a9e53
 Built:        Fri Jan 13 21:41:57 2017
 OS/Arch:      linux/amd64
 Experimental: false

Output of docker info:

Containers: 12
 Running: 11
 Paused: 0
 Stopped: 1
Images: 154
Server Version: 1.13.0-rc7
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: active
 NodeID: q7o757o7elpwgmv1vfxr44slb
 Is Manager: true
 ClusterID: raj0ho1r6e623tb82bf50xne2
 Managers: 1
 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
  External CAs:
    cfssl: https://172.18.0.4:12381/api/v1/cfssl/sign
 Node Address: 172.18.0.4
 Manager Addresses:
  172.18.0.4:2377
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: 4.4.23-31.54.amzn1.x86_64
Operating System: Alpine Linux v3.5 (containerized)
OSType: linux
Architecture: x86_64
CPUs: 2
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Total Memory: 7.308 GiB
Name: 0fcdb7741aa4
ID: PXCS:W2IH:QXXT:IICR:UFD6:IOU3:WILG:AHEA:RXGD:3D7Z:2SNQ:LXPU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 119
 Goroutines: 221
 System Time: 2017-01-21T02:54:54.564212463Z
 EventsListeners: 2
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.): AWS

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

hwo to solve this problem

I experienced the same exact use case / problem as @jcrben while using Docker for Windows. I created a swap file in the container.

$ docker info
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 521
Server Version: 18.06.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.93-linuxkit-aufs
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d010324
ID: YNG4:J6W4:YYNM:MQDQ:E45H:3KGK:3L6E:JHZV:FSIV:2OOP:6TLF:YZ6F
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 24
 Goroutines: 47
 System Time: 2018-09-20T15:09:49.4076473Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

A temporary work around that worked for me was restarting Docker which allowed me to remove the container, but this problem is repeatable.

  1. Make swapfile in container with privileged mode
  2. Attempt to delete the container and it will fail with an in use error
  3. Trying to spawn a new container that makes the same swapfile will fail
  4. Restart Docker
  5. Things work until you do #1 again

In my case I’m running Docker inside of Docker to test some Ansible roles. Exactly how I’m running Docker is available in this gist https://gist.github.com/nickjj/d12353b5b601e33cd62fda111359957a.

Update: I strongly suspect that this was caused by mounting both the images and the containers directories from the host into the dind. I’ll try mounting only the images directories and that’ll probably solve the issue. I’ll close this if after the change I don’t see this happen for a week.

Looks like a different error; read-only file system could indicate your system ran out of space, and was put into read-only mode; e.g., see https://askubuntu.com/a/197468