create
Pulls/imports an image and consumes the complete progress response. HTTP 200 or a completed layer is not final success: Docker stream errors become an error Result. Callbacks are sequential and apply backpressure; callback exceptions and cancellation propagate. There is no implicit request/idle deadline. Cancelling closes the request without rolling back daemon work.
Return
Operation response on success, or the Docker error response. Transport failures and cancellation can throw.
Parameters
Image reference to pull, for example alpine:latest or registry.example.com/team/app:v1; also used to select stored registry credentials.
Optional import source forwarded to Docker; this overload does not upload an import body.
Destination repository name.
Image tag; null leaves tag selection to Docker.
Optional import commit message.
Dockerfile instructions applied by Docker during import.
Optional Docker platform selector, for example linux/amd64.
Samples
withTimeout(120_000) {
docker.images.create("alpine:latest") { progress ->
println("${progress.id.orEmpty()}: ${progress.status.orEmpty()}")
}.getOrThrow()
}
val id = docker.containers.create(name = name, config = ContainerCreateRequest(
image = "alpine:latest",
cmd = listOf("sh", "-c", "while true; do date; sleep 5; done"),
env = listOf("APP_MODE=development"),
)).getOrThrow().id
docker.containers.start(id).getOrThrow()
return idPulls/imports an image and consumes the complete progress response. HTTP 200 or a completed layer is not final success: Docker stream errors become an error Result. Callbacks are sequential and apply backpressure; callback exceptions and cancellation propagate. There is no implicit request/idle deadline. Cancelling closes the request without rolling back daemon work.
Return
Operation response on success, or the Docker error response. Transport failures and cancellation can throw.
Parameters
Image reference to pull, for example alpine:latest or registry.example.com/team/app:v1; also used to select stored registry credentials.
Optional import source forwarded to Docker; this overload does not upload an import body.
Destination repository name.
Image tag; null leaves tag selection to Docker.
Optional import commit message.
Dockerfile instructions applied by Docker during import.
Optional Docker platform selector, for example linux/amd64.
Suspending callback invoked sequentially for each progress record. Fields can be absent; progress counts describe a layer rather than the whole operation. Use the returned Result to determine completion, not status text or a percentage.
Samples
withTimeout(120_000) {
docker.images.create("alpine:latest") { progress ->
println("${progress.id.orEmpty()}: ${progress.status.orEmpty()}")
}.getOrThrow()
}
val id = docker.containers.create(name = name, config = ContainerCreateRequest(
image = "alpine:latest",
cmd = listOf("sh", "-c", "while true; do date; sleep 5; done"),
env = listOf("APP_MODE=development"),
)).getOrThrow().id
docker.containers.start(id).getOrThrow()
return id