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

build: enhance warning message when no output specified #1148

Merged
merged 1 commit into from
Jun 5, 2022

Conversation

crazy-max
Copy link
Member

fixes #968

fix the issue where no output warning message is being displayed for linked targets and also enhance this message to display which targets don't have an output specified.

# docker-bake.hcl

target "base" {
  dockerfile = "baseapp.Dockerfile"
  args = {
    basefoo = "bar"
  }
}

target "base2" {
  dockerfile = "baseapp.Dockerfile"
  args = {
    basefoo = "bar3"
  }
}

target "app" {
  contexts = {
    baseapp = "target:base"
  }
}
# Dockerfile
FROM baseapp
RUN echo "Hello world"
# baseapp.Dockerfile
FROM alpine
WORKDIR /src
$ docker buildx bake --set app.tags=user/app:latest --set app.output=type=cacheonly app
...
#5 [app 1/2] FROM docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c
#5 resolve docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c 0.0s done
#5 DONE 0.1s

#8 [base 2/2] WORKDIR /src
#8 CACHED

#9 [app 1/2] RUN echo "Hello world"
#9 CACHED

#8 [app 2/2] WORKDIR /src
#8 CACHED
$ docker buildx bake --set app.tags=user/app:latest --set app.output=type=cacheonly app base2
...
#7 [app 1/2] FROM docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c
#7 resolve docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c 0.0s done
#7 DONE 0.1s

#8 [app 2/2] WORKDIR /src
#8 CACHED
WARNING: No output specified for base2 target(s) with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
$ docker buildx bake base base2
...
#6 [base2 1/2] FROM docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c
#6 resolve docker.io/library/alpine@sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c 0.0s done
#6 DONE 0.0s

#7 [base 2/2] WORKDIR /src
#7 CACHED
WARNING: No output specified for base, base2 target(s) with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
$ docker buildx build --build-context baseapp=docker-image://alpine .
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 85B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.1s
...

Signed-off-by: CrazyMax [email protected]

@crazy-max crazy-max requested a review from tonistiigi June 1, 2022 10:12
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

Could the Linked property just be a helper function isLinked(targets, target) bool ?

@crazy-max
Copy link
Member Author

@tonistiigi As discussed yesterday, we can't check current targets to find out if it's a linked one as it could also be explicitly specified by the user. See second example in #1148 (comment).

@crazy-max crazy-max requested a review from tonistiigi June 3, 2022 13:52
@tonistiigi
Copy link
Member

Let's add a comment that Linked means the user did not request this target to be built.

@crazy-max crazy-max merged commit 6cb026b into docker:master Jun 5, 2022
@crazy-max crazy-max deleted the fix-no-output-warn branch June 5, 2022 15:30
@crazy-max crazy-max added this to the v0.9.0 milestone Jun 5, 2022
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.

"No output specified for" warning should be handled for named contexts
2 participants