Skip to content

✨ Import image to local container runtime #8025

Closed

Description

@jedevc

The CLI should support loading images into the local container image store - whether that's docker, containerd through ctr/nerdctl, podman, etc.

Today, this might look something like:

$ dagger call container-echo --string-arg=foo -o ./image.tar
$ docker load -i ./image.tar

However, we should really have a native way to do this - something like:

$ dagger call container-echo --string-arg=foo --load <image>:<tag>

Why?

So how would this work?

  • The CLI should have support for a generic "loader" interface - these take a core container object, and somehow "load" them. We can implement two loaders to start:
    • docker load (the default)
    • Containerd content store streaming, implemented using the session attachables that buildkit itself has - we can allow forwarding a local containerd socket api, or opening a local content store (as the oci export in buildkit uses).
  • The syntax could then look something like:
    • dagger call container-echo --string-arg=foo --load <image>:<tag> to load into the default docker store
    • dagger call container-echo --string-arg=foo --load ./path/to/oci/layout/<image>:<tag> to export to a local oci layout
    • dagger call container-echo --string-arg=foo --load ./path/to/containerd/socket to load to the containerd store accessible via that API

Related:

Activity

  1. added this to the next milestone on Jul 24, 2024
  2. verdverm commented on Jul 25, 2024

    @verdverm
    Contributor

    Forgot about the tagging part, for context, here is the code I use in one project

    // writes images into docker daemon on host
    export default async function build(cfg: Record<string,any>, client: Client) {
    	// Dagger Containers
    	const imgs = await images(cfg, client)
    
    	const output = async (img: Container, name: string) => {
    		const fullName = `${name}:dirty`
    		const fullTar = `/tmp/${fullName}.tar`
    
    		// write tar file, triggers actual image building
    		await img.export(fullTar)
    
    		// load into docker
    		const { stdout } = await exec(`docker load -i ${fullTar}`)
    		const sha = stdout.split(":")
    		const hash = sha[sha.length-1].trim()
    
    		// tag image
    		await exec(`docker tag ${hash} ts/${fullName}`)
    
    		// cleanup tar file
    		await exec(`rm ${fullTar}`)
    	}
    
            // doing this in parallel will make your computer warm...
    	await Promise.all(cfg.components.map(async (c) => {
    		await output(await imgs[c], cfg[c].name)
    	}))
    }
  3. added
    area/engine
    on Aug 7, 2024
  4. VasiliyS commented on Nov 7, 2024

    @VasiliyS

    That would be a much welcomed feature!

    In my case, I'd like to automate the container workflow for local dev and testing for a library I'm developing. In a nutshell, the library is a client which interacts with a server. This server is under active development and therefore a functionality is needed to automate bootstrapping dev/test/demo environment against various git refs.

    Also, the users of the library will benefit from the ability to have all bootstrapping done for them for learning and development.

    Currently, I'm exporting and loading a tarball, but it's slow and feels kind of wasteful.

    BTW, to deal with tagging, one can simply annotate the container with io.containerd.image.name prior to asTarball call. docker load -i picks up the annotation, including the tag.

  5. nalum commented on May 30, 2025

    @nalum

    Just came across this, has there been any progress on adding support?

  6. akkuman commented on Jun 25, 2025

    @akkuman

    Considering the existence of https://github.com/psviderski/unregistry, I feel that importing images directly into the local is a necessary feature that avoids unnecessary overhead or can directly provide functionality similar to this tool

  7. self-assigned this
    on Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/engine

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions