Skip to content

Container

A running or stopped container.

Fields

cmd @ (Array[Str] | nil) [get, set]

Command, or nil when unset.

created @ (Str | nil) [get, set]

Creation timestamp, as the runtime reports it.

entrypoint @ (Array[Str] | nil) [get, set]

Entrypoint, or nil when unset.

id @ Str [get, set]

Full container ID.

image @ (Str | nil) [get, set]

Image reference the container was created from.

image_id @ (Str | nil) [get, set]

ID of the image the container was created from.

labels @ (Dict[Str, Str] | nil) [get, set]

Labels, or nil when the container has none.

Methods

kill()

Kills the container.

remove …

Removes the container.

Parameters

NameTypeDescription
:force? Bool Remove the container even if it is running.
:volumes? Bool Also remove its anonymous volumes.

restart …

Restarts the container.

Parameters

NameTypeDescription
:timeout? Int Seconds to wait before killing the container. Defaults to the runtime's.

start()

Starts the container.

state() -> ContainerState

Returns the container's live state.

stop …

Stops the container.

Parameters

NameTypeDescription
:timeout? Int Seconds to wait before killing the container. Defaults to the runtime's.

wait()

Waits for the container to stop.

Errors

ContainerExitError for a nonzero exit status.

with[R] func … -> R

Runs func in this running container through a VFS context.

Filesystem access, spawned programs, environment, and working directory use the container for the duration of func. A dolang-vfs helper is copied into the container's /tmp and removed once the connection starts, if the container user may remove it.

Parameters

NameTypeDescription
func (() -> R) Block to run.
:cd? (Str | fs.Path) Initial working directory.
:env? Env Environment overrides. nil unsets a variable.