5a1d4bff62
This adds support to loading artifacts (e.g. docker.#Build, os.#Container, ...) into any arbitrary docker engine (through a dagger.#Stream for UNIX sockets or SSH for a remote engine) Implementation: - Add op.#SaveImage which serializes an artifact into an arbitrary path (docker tarball format) - Add docker.#Load which uses op.#SaveImage to serialize to disk and executes `docker load` to load it back Caveats: Because we're doing this in userspace rather than letting dagger itself load the image, the performance is pretty bad. The buildkit API is meant for streaming (get a stream of a docker image pipe it into docker load). Because of userspace, we have to load the entire docker image into memory, then serialize it in a single WriteFile LLB operation. Example: ```cue package main import ( "alpha.dagger.io/dagger" "alpha.dagger.io/docker" ) source: dagger.#Input & dagger.#Artifact dockersocket: dagger.#Input & dagger.#Stream build: docker.#Build & { "source": source } load: docker.#Load & { source: build tag: "testimage" socket: dockersocket } ``` Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com> |
||
---|---|---|
.. | ||
compose.md | ||
README.md |
sidebar_label |
---|
docker |
alpha.dagger.io/docker
Docker container operations
import "alpha.dagger.io/docker"
docker.#Build
Build a Docker image from source
docker.#Build Inputs
Name | Type | Description |
---|---|---|
source | dagger.#Artifact |
Build context |
dockerfile | *null | string |
Dockerfile passed as a string |
docker.#Build Outputs
No output.
docker.#Command
A container image that can run any docker command
docker.#Command Inputs
Name | Type | Description |
---|---|---|
command | string |
Command to execute |
registries | [] |
Image registries |
docker.#Command Outputs
No output.
docker.#Load
Load a docker image into a docker engine
docker.#Load Inputs
Name | Type | Description |
---|---|---|
tag | string |
Name and optionally a tag in the 'name:tag' format |
source | dagger.#Artifact |
Image source |
load.command | "docker load -i /src/image.tar" |
Command to execute |
load.registries | [] |
Image registries |
docker.#Load Outputs
Name | Type | Description |
---|---|---|
ref | string |
Image ref |
digest | string |
Image digest |
docker.#Pull
Pull a docker container
docker.#Pull Inputs
Name | Type | Description |
---|---|---|
from | string |
Remote ref (example: "index.docker.io/alpine:latest") |
docker.#Pull Outputs
No output.
docker.#Push
Push a docker image to a remote registry
docker.#Push Inputs
Name | Type | Description |
---|---|---|
target | string |
Remote target (example: "index.docker.io/alpine:latest") |
source | dagger.#Artifact |
Image source |
docker.#Push Outputs
Name | Type | Description |
---|---|---|
ref | string |
Image ref |
digest | string |
Image digest |
docker.#Run
docker.#Run Inputs
Name | Type | Description |
---|---|---|
ref | string |
Image reference (e.g: nginx:alpine) |
run.command | """\n # Run detach container\n OPTS=""\n \n if [ ! -z "$CONTAINER_NAME" ]; then\n \tOPTS="$OPTS --name $CONTAINER_NAME"\n fi\n \n if [ ! -z "$CONTAINER_PORTS" ]; then\n \tOPTS="$OPTS -p $CONTAINER_PORTS"\n fi\n \n docker container run -d $OPTS "$IMAGE_REF"\n """ |
Command to execute |
run.env.IMAGE_REF | string |
- |
run.registries | [] |
Image registries |
docker.#Run Outputs
No output.