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

podman build --squash also squashes layers of base container #1234

Closed
mlschroe opened this issue Dec 13, 2018 · 17 comments · Fixed by containers/podman#4215
Closed

podman build --squash also squashes layers of base container #1234

mlschroe opened this issue Dec 13, 2018 · 17 comments · Fixed by containers/podman#4215
Assignees
Labels
from Podman This issue was either first reported on the Podman issue list or when running 'podman build' locked - please file new issue/PR

Comments

@mlschroe
Copy link

Description

podman build --squash squashes all layers into a single layer, whereas docker build --squash only squashes the new layers but keeps the layers from the base container. Is this difference intentional? It IMHO limits the usefulness of the --squash option quite a bit.

Steps to reproduce the issue:

  1. podman build --squash

Describe the results you received:
The created container has only one layer.

Describe the results you expected:
The layers of the base container should be kept intact.

Output of rpm -q buildah or apt list buildah:

buildah-1.5-1.1.x86_64

Output of buildah version:

Version:         1.5
Go Version:      go1.11.1
Image Spec:      1.0.0
Runtime Spec:    1.0.0
CNI Spec:        0.4.0
libcni Version:  v0.7.0-alpha1
Git Commit:      87239ae7046ea3a25f644cd0789b3d6678dc144d
Built:           Fri Nov 23 12:00:00 2018
OS/Arch:         linux/amd64

Output of podman version if reporting a podman build issue:

Version:       0.11.1.1
Go Version:    go1.11.1
OS/Arch:       linux/amd64
@TomSweeneyRedHat
Copy link
Member

@rhatdan @umohnani8 WDYT?

@rhatdan
Copy link
Member

rhatdan commented Dec 13, 2018

Definitely not intentional, we want to match Docker behaviour.

@pkubatrh
Copy link

pkubatrh commented Mar 7, 2019

Also hit this today while trying to see what to use instead of docker-squash in our workflow.

@vrothberg
Copy link
Member

This one must have slipped over Christmas. Thanks for the report and the ping. We'll have a look.

@TomSweeneyRedHat
Copy link
Member

@pkubatrh or @mlschroe do either of you have a Dockerfile that reproduces this handy? If not, I'll try to dig one up.

@TomSweeneyRedHat
Copy link
Member

Never mind on the Dockerfile, I found a nice chunk on https://stackoverflow.com/questions/42786991/docker-squash-behavior

@rhatdan
Copy link
Member

rhatdan commented Apr 12, 2019

@nalind @TomSweeneyRedHat Whats the scoop on this one? Does some of the stuff @nalind is working on fix it?

@TomSweeneyRedHat
Copy link
Member

Doesn't appear that @nanlind's changes fixed this, but I'll let him correct me.

@rhatdan
Copy link
Member

rhatdan commented Jun 8, 2019

@vrothberg @nalind @TomSweeneyRedHat Any progress on this?

@TomSweeneyRedHat
Copy link
Member

Not that I know of, sigh, slipped off the radar.

@MaciejKucia
Copy link

This seems a requirements problem since original committer has assumed that all layers shall be squashed.

c806e6e#diff-b9ec73f876c8864b1fbdbf9fd96b4690

Reusing base layers makes a lot of sense, especially when dealing with many images based on common FROM (for example RedHat UBI).

@nalind
Copy link
Member

nalind commented Jun 24, 2019

Agreed, this is essentially a mislabeling based on a misread of what squash was supposed to be doing. A squashed result from docker build is equivalent to our --layers=false, but there's not really a good time to rename flags in the CLI and in the APIs.

@TomSweeneyRedHat
Copy link
Member

@nalind is there something we can/should do with this or can we close this issue?

@mlschroe
Copy link
Author

(Wouldn't --layers=false lead to slower builds as intermediate layers are no longer re-used in builds? I'd prefer squashing the layers at the end of the build.)

@TomSweeneyRedHat TomSweeneyRedHat added the from Podman This issue was either first reported on the Podman issue list or when running 'podman build' label Sep 19, 2019
@TomSweeneyRedHat
Copy link
Member

I've been playing today looking at the experimental --squash option in Docker and comparing it to the Buildah commands and these commands appear to be equivalent (Note buildah bud sets --layers to false by default, podman build sets --layers to true by default):

// Retain all layers, squash none.
docker build == buildah bud --layers=true == podman build

// Squash all new layers into 1 layer, retain old layers
docker build --squash == buildah bud == podman buildah --layers=false

// Squash all layers (old and new) into 1 layer.
buildah bud --layers=true --squash == podman build --squash # No Docker equivalent found.

Given that, I'm proposing that we simply switch the functionality of the --squash and the --layers=false functionality in the buildah bud command. That way our --squash will line up with Docker's and the --layers=false functionality would create only one layer.

The one point of concern with this proposal would be the default buildah bud command will leave only one layer. There would be no change in functionality for the default podman build command.

If we go forward with this proposal, @nalind suggests holding until we are ready for at least a new minor release (i.e 1.12.0) in both Buildah and Podman.

mlschroe added a commit to openSUSE/obs-build that referenced this issue May 6, 2020
See containers/buildah#1234 for a discussion
about differences between podman and docker builds.
@graywolf-at-work
Copy link

Should this work? When I do buildah bud --squash and later try to pull the
images

+   $ docker pull shell-ci:xxx
xxx: Pulling from shell-ci
96470ff7e789: Pull complete
Digest: sha256:f52e76092abb54c485eab8dd5bf31579e10716e1673509fd64b83cb07dce3d14
Status: Downloaded newer image for shell-ci:xxx
shell-ci:xxx

but when I run buildah bud --layers=false, I do get:

+   $ docker pull shell-ci:xxx
xxx: Pulling from shell-ci
0329cb374ddf: Pull complete
425c89b8c674: Pull complete
4ca545ee6d5d: Pull complete
Digest: sha256:2d352967296e8dedb1b42e5feb650a3720dd5c925c6e6cdc5a3e825b7bbcb170
Status: Downloaded newer image for shell-ci:xxx
shell-ci:xxx

Dockerfiles are created in this order:

  1. base (FROM scratch)
  2. base-ci (FROM base)
  3. shell-ci (FROM base-ci)

My buildah version is

+   $ buildah --version
buildah version 1.14.9 (image-spec 1.0.1-dev, runtime-spec 1.0.1-dev)

@rhatdan
Copy link
Member

rhatdan commented Jun 15, 2020

Could you see if Docker is having issues with OCI Images.

Build the image with --format docker and see if you have the same problems.

lehc1m pushed a commit to lehc1m/obs-build that referenced this issue Dec 3, 2020
See containers/buildah#1234 for a discussion
about differences between podman and docker builds.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
from Podman This issue was either first reported on the Podman issue list or when running 'podman build' locked - please file new issue/PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants