# `Tank.Container`
[🔗](https://github.com/oshlabs/tank/blob/v0.2.0/lib/tank/container.ex#L1)

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).
  * `mounts` — `Tank.Mount`s, 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 {: .info}
> This is the *desired-state struct*. The supervised GenServer that brings a
> container to life is `Tank.Runtime`.

# `image`

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

# `t`

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

# `new`

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

Build a validated container from a map or keyword list.

# `new!`

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

Like `new/1` but raises `ArgumentError` on invalid input.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
