Make docker/cli image overrideable

Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
This commit is contained in:
Helder Correia 2022-03-28 14:34:15 +00:00
parent 9f042800da
commit cf0fcdbe92
No known key found for this signature in database
GPG Key ID: C6490D872EF1DCA7
2 changed files with 24 additions and 11 deletions

View File

@ -5,17 +5,21 @@ import (
"universe.dagger.io/docker" "universe.dagger.io/docker"
) )
// See https://github.com/dagger/dagger/issues/1856 // See https://github.com/dagger/dagger/discussions/1874
// Default image
#Image: docker.#Pull & {
source: "docker:20.10.13-alpine3.15"
}
// Run a docker CLI command // Run a docker CLI command
#Run: { #Run: {
#RunSocket | #RunSSH | #RunTCP #RunSocket | #RunSSH | #RunTCP
_image: docker.#Pull & { _defaultImage: #Image
source: "docker:20.10.13-alpine3.15"
}
input: _image.output // As a convenience, input defaults to a ready-to-use docker environment
input: docker.#Image | *_defaultImage.output
} }
// Connect via local docker socket // Connect via local docker socket

View File

@ -4,6 +4,7 @@ import (
"dagger.io/dagger" "dagger.io/dagger"
"universe.dagger.io/alpine" "universe.dagger.io/alpine"
"universe.dagger.io/docker"
"universe.dagger.io/docker/cli" "universe.dagger.io/docker/cli"
) )
@ -17,19 +18,27 @@ dagger.#Plan & {
} }
differentImage: { differentImage: {
_cli: alpine.#Build & { _cli: docker.#Build & {
packages: { steps: [
bash: {} alpine.#Build & {
"docker-cli": {} packages: "docker-cli": {}
} },
docker.#Run & {
command: {
name: "sh"
flags: "-c": "echo -n foobar > /test.txt"
}
},
]
} }
run: cli.#RunSocket & { run: cli.#Run & {
input: _cli.output input: _cli.output
host: client.filesystem."/var/run/docker.sock".read.contents host: client.filesystem."/var/run/docker.sock".read.contents
command: { command: {
name: "docker" name: "docker"
args: ["info"] args: ["info"]
} }
export: files: "/test.txt": "foobar"
} }
} }