Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCKER_BUILDKIT=1 docker build --squash should not squash the base image #38903

Open
AkihiroSuda opened this issue Mar 19, 2019 · 8 comments · May be fixed by #39187
Open

DOCKER_BUILDKIT=1 docker build --squash should not squash the base image #38903

AkihiroSuda opened this issue Mar 19, 2019 · 8 comments · May be fixed by #39187
Labels
area/builder kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. kind/experimental

Comments

@AkihiroSuda
Copy link
Member

AkihiroSuda commented Mar 19, 2019

Description

Steps to reproduce the issue:
DOCKER_BUILDKIT=1 docker build --iidfile /tmp/iid --squash . && docker save $(cat /tmp/iid) | tar t | grep layer.tar | wc -l

Describe the results you received:
1

Describe the results you expected:
2

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

Output of docker version:

Client:
 Version:           master-dockerproject-2019-03-18
 API version:       1.40
 Go version:        go1.11.6
 Git commit:        8c3a619d
 Built:             Mon Mar 18 23:39:36 2019
 OS/Arch:           linux/amd64
 Experimental:      true

Server:
 Engine:
  Version:          master-dockerproject-2019-03-18
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.1
  Git commit:       36d2c8b
  Built:            Mon Mar 18 23:46:08 2019
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          v1.2.5
  GitCommit:        bb71b10fd8f58240ca47fbb579b9d1028eea7c84
 runc:
  Version:          1.0.0-rc6+dev
  GitCommit:        8011af4a96d657f5ab1cff56273308dd1e13c9eb
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker info:

Client:
 Debug Mode: false

Server:
 Containers: 10
  Running: 0
  Paused: 0
  Stopped: 10
 Images: 53
 Server Version: master-dockerproject-2019-03-18
 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 local logentries splunk syslog
 Swarm: inactive
 Runtimes: runsc-kvm kata runc runnc runsc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: bb71b10fd8f58240ca47fbb579b9d1028eea7c84
 runc version: 8011af4a96d657f5ab1cff56273308dd1e13c9eb
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.15.0-46-generic
 Operating System: Ubuntu 18.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.767GiB
 Name: suda-ws01
 ID: 59b7cdb8-1482-4653-a6ed-08d50b808573
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 22
  Goroutines: 43
  System Time: 2019-03-19T20:03:22.250407091+09:00
  EventsListeners: 0
 Username: akihirosuda
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support

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

@AkihiroSuda AkihiroSuda added the kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. label Mar 19, 2019
@thaJeztah thaJeztah added kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. and removed kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. labels Mar 19, 2019
@thaJeztah
Copy link
Member

I changed this to "bug", as this is a breaking change for people that switch from the legacy builder

@thaJeztah
Copy link
Member

/cc @tonistiigi

@Blyschak
Copy link

Blyschak commented May 6, 2019

Hi, is there any update regarding this issue? or any plan when to fix in 18.09?

@AkihiroSuda
Copy link
Member Author

No update but PR is always welcome

@Blyschak Blyschak linked a pull request May 8, 2019 that will close this issue
@Blyschak
Copy link

Blyschak commented May 8, 2019

Appreciate if anyone can take a look at #39187 and give comments

@jhwillett
Copy link

Hi: sorry to intrude, I can't find where else to ask about this. I'm a Docker user but not a contributor.

I've just discovered that env DOCKER_BUILDKIT=1 docker build --squash in Docker version 19.03.4, build 9013bf5 does squash my base image, and I'm excited to find this after iterating on disappointing results from stock docker build --squash.

Ramping up now on BuildKit, I'm concerned to see that this behavior (which I like) is treated as a bug.

I take the point very well, that switching to DOCKER_BUILDKIT=1 should be completely backward-compatible, and that many or most users of the original builder expect --squash to yield one layer per base image. By the Principle of Least surprise, yes, it should be a bug for --squash to change when DOCKER_BUILDKIT changes.

But also: for my use case, I prefer the behavior which produces only a single layer.

Is there any chance that support for the new behavior could be preserved, probably via a different flag?

I'm aware of docker-squash but it is very slow and seems less-maintained. If BuildKit stops supporting "squash to just 1 layer", are there other alternatives I could investigate?

Thanks - and again sorry if this is the wrong forum for this discussion.

@kiorky
Copy link
Contributor

kiorky commented Nov 14, 2020

Another related problem trying to solve the need to keep the squashing up to the FROM layer:

I'm currently using buildkit to build the image, and then still relying on legacy builder to squash it

To reproduce, just do

echo | DOCKER_BUILDKIT=1 docker build -t a -<<EOF
FROM busybox
RUN touch foo
RUN touch foo2
RUN touch foo3
EOF
echo "FROM a"| DOCKER_BUILDKIT="" docker build --squash -t b -

I tried with to build an image with docker:20.10.0-beta1-dind and DOCKER_BUILDKIT= which fails with

docker build --squash -t *** -
Error response from daemon: experimental session with v1 builder is no longer supported,
use builder version v2 (BuildKit) instead

The same is working with current docker:dind

@thaJeztah
Copy link
Member

@kiorky the error about experimental session ("Error response from daemon: experimental session with v1 builder is no longer supported...") is unrelated; that error is fixed in #41648, which will be in the next beta/rc of docker 20.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/builder kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. kind/experimental
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants