docker / docker/cli

Builder prune fails due to out of memory error (dockerd killed by system)

Open
#3,633 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area/builder area/builder/buildkit kind/bug
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Description

docker builder prune --keep-storage 40G fails due to Out of memory error (dockerd get killed by system)

Steps to reproduce the issue:
I've got my /var/lib/docker/overlay2 folder size more than 140GB and decided to prune builder cache.
The command above makes my system freeze for a couple of minutes (100% CPU usage). Then dockerd get killed by system due OOM. The command exits with sock EOF error.

Describe the results you received:

Out of memory: Killed process 2974 (dockerd) total-vm:26067224kB, anon-rss:15399372kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:33588kB oom_score_adj:0

error during connect: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.41/build/prune?filters=&keep-storage=42949672960": EOF

Describe the results you expected:
I expected it to clean some build caches. At least do not freeze the system and report some error.

Output of docker version:

~ docker version
Client:
 Version:           20.10.16
 API version:       1.41
 Go version:        go1.18.1
 Git commit:        aa7e414fdc
 Built:             Sat May 14 12:48:33 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.16
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.1
  Git commit:       f756502055
  Built:            Sat May 14 12:47:27 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.6.4
  GitCommit:        212e8b6fa2f44b9c21b2798135fc6fb7c53efc16.m
 runc:
  Version:          1.1.2
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
  compose: Docker Compose (Docker Inc., 2.5.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 3964
 Server Version: 20.10.16
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 212e8b6fa2f44b9c21b2798135fc6fb7c53efc16.m
 runc version: 
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.17.7-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.31GiB
 Name: thinkpad
 ID: DI7T:5UHB:CMTB:7H4G:JFEB:WRUQ:S7CC:PSGQ:43QP:IBJQ:R6YM:PITQ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: nikitos1
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Default Address Pools:
   Base: 192.168.128.0/20, Size: 24

Additional environment details:
I'm using Thinkpad X1 gen7 laptop with ArchLinux.

# uname -a
Linux thinkpad 5.17.7-arch1-1 #1 SMP PREEMPT Thu, 12 May 2022 18:55:54 +0000 x86_64 GNU/Linux
# free -m
               total        used        free      shared  buff/cache   available
Mem:           15682        1740       11457         449   
Swap:              0           0           0

That issue might be related, although it has slightly different symptoms: docker/for-mac/issues/2501

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing docker builder prune --keep-storage 40G with the reported Docker, Arch Linux, overlay2, and no-swap environment. Trace the builder-prune entry point and daemon behavior to determine where memory grows or work becomes excessive. Done means pruning completes or fails without freezing the system or causing dockerd to be killed, with a useful error reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
backend, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.