Tank.Container (Tank v0.1.0)

Copy Markdown View Source

A container's desired state inside a pod.

The OCI image config supplies defaults; these fields override it (see Tank.OCI): command overrides the image Entrypoint and args overrides Cmd — and as in Docker, setting command resets Cmd. env is merged over the image Env; working_dir and user override the image's, with user resolved against the rootfs's /etc/passwd and /etc/group.

  • image — an OCI reference ("nginx:1.27") or the {:rootfs, path} escape hatch (an already-assembled rootfs directory).
  • mountsTank.Mounts, each naming a pod-level Tank.Volume.
  • limits — a map of cgroup limits: :memory (bytes), :pids, :cpu ({quota_us, period_us}).
  • tty — when true, the container's main process runs on a PTY (rather than /dev/null), so Tank.attach/1 can take over its terminal. Use it for a container that is an interactive shell. Default false.

Not the runtime

This is the desired-state struct. The supervised GenServer that brings a container to life is Tank.Runtime.

Summary

Functions

Build a validated container from a map or keyword list.

Like new/1 but raises ArgumentError on invalid input.

Types

image()

@type image() :: String.t() | {:rootfs, Path.t()}

t()

@type t() :: %Tank.Container{
  args: [String.t()],
  command: [String.t()],
  env: %{optional(String.t()) => String.t()},
  image: image(),
  limits: map(),
  mounts: [Tank.Mount.t()],
  name: String.t(),
  tty: boolean(),
  user: String.t() | nil,
  working_dir: String.t() | nil
}

Functions

new(attrs)

@spec new(map() | keyword()) :: {:ok, t()} | {:error, term()}

Build a validated container from a map or keyword list.

new!(attrs)

@spec new!(map() | keyword()) :: t()

Like new/1 but raises ArgumentError on invalid input.