Skip to content

Container

A running or stopped container.

Fields

cmd @ (Array[Str] | nil)

Command, or nil when unset.

created @ (Str | nil)

Creation timestamp, as the runtime reports it.

entrypoint @ (Array[Str] | nil)

Entrypoint, or nil when unset.

id @ Str

Full container ID.

image @ (Str | nil)

Image reference the container was created from.

image_id @ (Str | nil)

ID of the image the container was created from.

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

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.

A matching dolang-vfs helper is copied to a session-specific path under /tmp and launched with the container runtime's exec command. The helper is removed after the VFS connection starts when the container user has permission to do so.

Parameters

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