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

invoke: load defaults from image config #1324

Merged
merged 1 commit into from
Oct 13, 2022

Conversation

jedevc
Copy link
Collaborator

@jedevc jedevc commented Sep 20, 2022

If user does not specify image certain container parameters, we can load them from the exporter metadata 🎉 This is mostly to scratch the itch that most of the time when debugging an image, I want to run it exactly as how it would be launched by docker.

Additionally, we introduce a new "default" value for the --invoke flag, that keeps all of the default parameters (since cobra does not have an easy way of accepting an optional flag argument).

Example with overriding the USER:

#syntax=docker/dockerfile:1
FROM ubuntu:22.04
RUN useradd -ms /bin/bash foo
USER foo
$ BUILDX_EXPERIMENTAL=1 docker buildx build --invoke sh .
...
Launching interactive container. Press Ctrl-a-c to switch to monitor console
$ whoami
foo

I'm not sure about the interaction of CMD and ENTRYPOINT here, it doesn't feel right, but I can't quite find the logic of how they're joined together in moby.

CC @ktock

@jedevc jedevc requested a review from tonistiigi September 20, 2022 15:29
build/build.go Outdated
}
env := cfg.Env
if env == nil && img != nil {
env = img.Config.Env
Copy link
Member

Choose a reason for hiding this comment

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

I think image env should be always set. If user sets own env they are added on top of image like in docker run

build/build.go Outdated Show resolved Hide resolved
If user does not specify image certain container parameters, we can load
them from the exporter metadata.

Additionally, we introduce a new "default" value for the --invoke flag,
that keeps all of the default parameters (since cobra does not have an
easy way of accepting an optional flag argument).

Signed-off-by: Justin Chadwell <[email protected]>
@jedevc jedevc requested a review from tonistiigi October 10, 2022 10:03
@tonistiigi tonistiigi merged commit ac85f59 into docker:master Oct 13, 2022
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

Successfully merging this pull request may close these issues.

3 participants