create

suspend fun create(fromImage: String, fromSrc: String? = null, repo: String? = null, tag: String? = null, message: String? = null, changes: List<String>? = null, platform: String? = null): Result<Unit, ErrorResponse>

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

fromImage

Image reference to pull, for example alpine:latest or registry.example.com/team/app:v1; also used to select stored registry credentials.

fromSrc

Optional import source forwarded to Docker; this overload does not upload an import body.

repo

Destination repository name.

tag

Image tag; null leaves tag selection to Docker.

message

Optional import commit message.

changes

Dockerfile instructions applied by Docker during import.

platform

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 id

suspend fun create(fromImage: String, fromSrc: String? = null, repo: String? = null, tag: String? = null, message: String? = null, changes: List<String>? = null, platform: String? = null, onProgress: suspend (ImageProgress<Unit>) -> Unit): Result<Unit, ErrorResponse>

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

fromImage

Image reference to pull, for example alpine:latest or registry.example.com/team/app:v1; also used to select stored registry credentials.

fromSrc

Optional import source forwarded to Docker; this overload does not upload an import body.

repo

Destination repository name.

tag

Image tag; null leaves tag selection to Docker.

message

Optional import commit message.

changes

Dockerfile instructions applied by Docker during import.

platform

Optional Docker platform selector, for example linux/amd64.

onProgress

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