Skip to content

feat: add host.containerImage to import containers from the host - #10810

Merged
jedevc merged 2 commits into
dagger:mainfrom
jedevc:add-image-loading-from-host
Aug 27, 2025
Merged

jedevc merged 2 commits into
dagger:mainfrom
jedevc:add-image-loading-from-host

Conversation

@jedevc

@jedevc jedevc commented Jul 29, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #10737 as a follow-up to #10662.

@jedevc jedevc added this to the v0.19.0 milestone Jul 29, 2025
@jedevc
jedevc force-pushed the add-image-loading-from-host branch from 3f8d9de to 8f0618a Compare July 29, 2025 15:16
@jedevc jedevc added area/engine/api needs/changelog Pull requests that require a changelog entry needs/docs Pull requests that require a docs change labels Jul 29, 2025
@jedevc
jedevc force-pushed the add-image-loading-from-host branch from 8f0618a to 62eb2f1 Compare July 29, 2025 16:47
@jedevc jedevc mentioned this pull request Jul 30, 2025
12 tasks done
@jedevc
jedevc force-pushed the add-image-loading-from-host branch 2 times, most recently from bc6b054 to 6201f96 Compare July 30, 2025 13:02
@jedevc jedevc linked an issue Jul 30, 2025 that may be closed by this pull request
@jedevc
jedevc force-pushed the add-image-loading-from-host branch 3 times, most recently from 9fc3b99 to 2d2a818 Compare August 4, 2025 13:20
@jedevc
jedevc marked this pull request as ready for review August 4, 2025 13:20
@jedevc
jedevc requested review from a team as code owners August 4, 2025 13:20
@guilhermedelyra

Copy link
Copy Markdown

hi! what's the status on this? 😁
looking forward on using this feature

Comment thread core/schema/host.go Resolved
@shykes

shykes commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

@jedevc how do you differentiate between "container instance" and "container image" on the host system?

@jedevc

jedevc commented Aug 18, 2025

Copy link
Copy Markdown
Contributor Author

This is probably a naming issue, this PR only lets you import images, not running containers.

I could call it host.Image? That might be clearer tbf, and matches exportImage.

@shykes

shykes commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

This is probably a naming issue, this PR only lets you import images, not running containers.

I could call it host.Image? That might be clearer tbf, and matches exportImage.

IMO Host.ContainerImage would be more explicit. Also leaves the door open for Host.ContainerInstance later? 😁

@shykes

shykes commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

Alternatively, you can keep Host.Container() (it's nice and short), and in the future we could add a fallback to lookup a container instance by name, if no image exists. The risk of conflict is pretty low between docker container instances & images... Maybe not worth polluting our API with the distinction.

@jedevc

jedevc commented Aug 18, 2025

Copy link
Copy Markdown
Contributor Author

I don't love ContainerImage - explicit yes, but we don't really have that same language anywhere else.

WDYT about having Host.image: Container and maybe one day later Host.container: Container (for the instance).

@shykes

shykes commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

I don't love ContainerImage - explicit yes, but we don't really have that same language anywhere else.

It's normal that we don't have that language anywhere else: Host.<foo> uses the host's vocabulary. So we should go for what is the most familiar to the user, in the context of the host system. In that context, the fact that Dagger doesn't strongly differentiate between container instance and image is irrelevant: it's the host's house so it's their rules, so to speak.

WDYT about having Host.image: Container and maybe one day later Host.container: Container (for the instance).

I think Image is too vague in the context of the host system. For example, is it a disk image of the whole host system? Etc.

@jedevc
jedevc force-pushed the add-image-loading-from-host branch from 97a62f6 to d69379b Compare August 19, 2025 12:52
@jedevc

jedevc commented Aug 19, 2025

Copy link
Copy Markdown
Contributor Author

Renamed from host.container to host.containerImage.

@jedevc jedevc changed the title feat: add host.container to import containers from the host feat: add host.containerImage to import containers from the host Aug 19, 2025
@jedevc
jedevc requested a review from shykes August 19, 2025 13:44
@jedevc jedevc removed this from the v0.19.0 milestone Aug 26, 2025
@jedevc
jedevc force-pushed the add-image-loading-from-host branch from d69379b to b286e85 Compare August 26, 2025 10:27
@jedevc
jedevc requested a review from vito August 26, 2025 14:19
@jedevc

jedevc commented Aug 26, 2025

Copy link
Copy Markdown
Contributor Author

If anyone has spare review time, don't think this one should be too hard!

@jedevc
jedevc force-pushed the add-image-loading-from-host branch from b286e85 to e481a99 Compare August 26, 2025 14:22

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm!

To be honest I'm also iffy on the name, but I see it's already been bikeshedded and I don't have a great proposal. I can see why Host.container was too vague. It's tempting to do something like Container.fromHostImage because then it sounds like the returned object is a "container" and not a "container image" but that would be inconsistent with other Host-loading things.

Maybe Host.containerFromImage would fix that for me, but then it's getting a bit long, and even despite the length is still vague (what kind of image? maybe this is really from a container runtime? but is there a good word for that everyone would grok?).

🤔 🤔

ctx, span := otel.Tracer("").Start(ctx, "save "+name)
defer telemetry.End(span, func() error { return rerr })

cmd := exec.CommandContext(ctx, "container", "image", "save", name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh nice, was wondering what things this would be compatible with, glad it's extensible

@jedevc jedevc added this to the v0.18.17 milestone Aug 27, 2025
@jedevc

jedevc commented Aug 27, 2025 •

Copy link
Copy Markdown
Contributor Author

Thanks for the approve 🙏

I'll merge for now, I'm not super in love with containerImage either - happy to continue the discussion and update it if we come up with a better option before the next release v0.18.17 next week.

I don't really like Container.fromHostImage, keeping it on host feels important. Host.containerFromImage is quite wordy, so I don't love that either 😆

@jedevc
jedevc merged commit 2cee53d into dagger:main Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/engine/api needs/changelog Pull requests that require a changelog entry needs/docs Pull requests that require a docs change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Import image from local container runtime 📖 Add import image from docker guide

5 participants