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

--rm=false does not keep intermediate containers as expected #1470

Closed
bkomraz1 opened this issue Apr 30, 2020 · 3 comments
Closed

--rm=false does not keep intermediate containers as expected #1470

bkomraz1 opened this issue Apr 30, 2020 · 3 comments

Comments

@bkomraz1
Copy link

Issue description

DOCKER_BUILDKIT=1 docker build --rm=false . does not keep intermediate containers as docker build --rm=false . keeps

# Dockerfile
FROM alpine:latest
LABEL debug=true

FROM alpine:latest

Steps to reproduce the issue

  1. docker system prune -f
  2. DOCKER_BUILDKIT=1 docker build --rm=false .
  3. docker ps -a -f label=debug=true

What's the expected result?

Step 1/3 : FROM alpine:latest
 ---> f70734b6a266
Step 2/3 : LABEL debug=true
 ---> Running in 773f64e4fbbe
 ---> d941f8903851
Step 3/3 : FROM alpine:latest
 ---> f70734b6a266
Successfully built f70734b6a266
CONTAINER ID        IMAGE               COMMAND                  CREATED                  STATUS              PORTS               NAMES
773f64e4fbbe        f70734b6a266        "/bin/sh -c '#(nop) …"   Less than a second ago   Created                                 friendly_heyrovsky

What's the actual result?

[+] Building 0.2s (5/5) FINISHED
 => [internal] load build definition from Dockerfile                                                                                         0.1s
 => => transferring dockerfile: 98B                                                                                                          0.1s
 => [internal] load .dockerignore                                                                                                            0.1s
 => => transferring context: 2B                                                                                                              0.1s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                             0.0s
 => CACHED [stage-1 1/1] FROM docker.io/library/alpine:latest                                                                                0.0s
 => exporting to image                                                                                                                       0.0s
 => => exporting layers                                                                                                                      0.0s
 => => writing image sha256:db489feeb4704a920c415104748a2ceef4e8e97882957f8e279813bc362a040f                                                 0.0s
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
@tonistiigi
Copy link
Member

#1472

@alexanderkjeldaas
Copy link

This issue should not be closed in favor of #1472 as #1472 only addresses one use-case.

Let me give a different use-case which belongs to this ticket: pushing intermediate images using labels.

See old thread in the docker forum here, SO question here etc.

Running docker multiple times is typically not a solution as this can be inside a complex CI/CD pipeline where a gazillion parameters are given to docker.

The previous recommended approach was using the LABEL command and then filter images based on this. This is a robust approach that composes well with any build system, unlike approaches requiring multiple invocations.

@TBBle
Copy link
Collaborator

TBBle commented Feb 3, 2022

Intermediate images are quite different from intermediate containers.

This ticket was asking about the latter, and was closed because (I assume) #1472 contains the discussion about why BuildKit doesn't have the sort of intermediate containers that docker build had, and is hence infeasible, in the second and third paragraphs.

The use-case of pushing multiple targets from a build as individual images is interesting, but that seems like an unrelated feature request for this ticket. (Also only tangentially related to #1472: whatever debugging approach is implemented, and generating multiple images in a single build, might have some implementation details in common, but those aspects already exist in BuildKit, so the remaining effort would be minimally-shared.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants