The Wayback Machine - https://web.archive.org/web/20260314082855/https://github.com/moby/moby/pull/37178
Skip to content

builder: fix layer leak on multi-stage wildcard copy#37178

Merged
vdemeester merged 1 commit intomoby:masterfrom
tonistiigi:layer-leak
May 31, 2018
Merged

builder: fix layer leak on multi-stage wildcard copy#37178
vdemeester merged 1 commit intomoby:masterfrom
tonistiigi:layer-leak

Conversation

@tonistiigi
Copy link
Member

fixes #37077

Signed-off-by: Tonis Tiigi tonistiigi@gmail.com

@thaJeztah

This comment has been minimized.

@thaJeztah

This comment has been minimized.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@codecov
Copy link

codecov bot commented May 30, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@0a94468). Click here to learn what that means.
The diff coverage is 0%.

@@            Coverage Diff            @@
##             master   #37178   +/-   ##
=========================================
  Coverage          ?   34.99%           
=========================================
  Files             ?      615           
  Lines             ?    45930           
  Branches          ?        0           
=========================================
  Hits              ?    16074           
  Misses            ?    27745           
  Partials          ?     2111

@thaJeztah
Copy link
Member

Looking good now:

Build, and start development container;

make BIND_DIR=. binary shell

Start daemon in the container;

make install
dockerd --debug &> /var/log/dockerd.log &

Create the test-script;

#!/bin/sh
set -e

build_image_ok() {
	docker image build --quiet --no-cache -t my_app:$1 -<<-EOF 1> /dev/null
		FROM busybox AS build
		RUN touch /vraag.html
		FROM scratch
		COPY --from=build /vraag.html ./
	EOF

	docker image prune -af | tail -1

	printf "Directories in /var/lib/docker/overlay2: "
	find /var/lib/docker/overlay2 -maxdepth 1 -type d | wc -l
}

build_image_faulty() {
	docker image build --quiet --no-cache -t my_app:$1 -<<-EOF 1> /dev/null
		FROM busybox AS build
		RUN touch /vraag.html
		FROM scratch
		COPY --from=build /*.html ./
	EOF

	docker image prune -af | tail -1

	printf "Directories in /var/lib/docker/overlay2: "
	find /var/lib/docker/overlay2 -maxdepth 1 -type d | wc -l
}

run_test() {
	echo "Running ok case:"
	i=1
	while [ $i -le 3 ]; do
		build_image_ok $i
		i=$(( i+1 ))
	done

	echo ""
	echo "Running faulty case:"
	i=1
	while [ $i -le 3 ]; do
		build_image_faulty $i
		i=$(( i+1 ))
	done
}

run_test

Run the test;

chmod +x ./repro-37077.sh
./repro-37077.sh 

Running ok case:
Total reclaimed space: 1.146MB
Directories in /var/lib/docker/overlay2: 2
Total reclaimed space: 1.146MB
Directories in /var/lib/docker/overlay2: 2
Total reclaimed space: 1.146MB
Directories in /var/lib/docker/overlay2: 2

Running faulty case:
Total reclaimed space: 1.146MB
Directories in /var/lib/docker/overlay2: 2
Total reclaimed space: 1.146MB
Directories in /var/lib/docker/overlay2: 2
Total reclaimed space: 1.146MB
Directories in /var/lib/docker/overlay2: 2

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@selansen
Copy link
Contributor

LGTM

Copy link
Contributor

@tiborvass tiborvass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inodes not freed after repeated builds - overlay

6 participants