Skip to main content

Loading an image into a docker engine

Dagger can build, run, push and pull docker images natively, without the need of a Docker engine. This feature is available in the package universe.dagger.io/docker.

However, sometimes after building an image, you specifically want to load it into your Docker engine. This is possible with the Docker CLI package: universe.dagger.io/docker/cli.

Using cli.#Load, you can load an image built by Dagger into a local or remote engine. It can be useful to debug or test a build locally before pushing.

Local daemon

Remote daemon, via SSH

package main

import (
"dagger.io/dagger"
"universe.dagger.io/docker"
"universe.dagger.io/docker/cli"
)

dagger.#Plan & {
client: filesystem: {
"~/.ssh/id_rsa": read: contents: dagger.#Secret
"~/.ssh/known_hosts": read: contents: dagger.#Secret
}

actions: {
build: docker.#Build & {
...
}

load: cli.#Load & {
image: build.output
tag: "myimage:v2"
host: "ssh://root@93.184.216.34"
ssh: {
key: client.filesystem."~/.ssh/id_rsa".read.contents
knownHosts: client.filesystem."~/.ssh/known_hosts".read.contents
}
}
}
}