# `Docker.Commands.Run`
[🔗](https://github.com/joshrotenberg/docker_wrapper_ex/blob/v0.1.2/lib/docker/commands/run.ex#L1)

Implements the `Docker.Command` behaviour for `docker run`.

Builds a `docker run` command with full support for ports, volumes,
environment variables, labels, capabilities, and resource constraints.

## Examples

    import Docker.Commands.Run

    "nginx:alpine"
    |> new()
    |> name("my-nginx")
    |> port(8080, 80)
    |> detach()
    |> Docker.run()

# `env_pair`

```elixir
@type env_pair() :: {String.t(), String.t()}
```

# `mount_spec`

```elixir
@type mount_spec() :: {String.t(), String.t(), String.t(), keyword()}
```

# `port_mapping`

```elixir
@type port_mapping() :: {non_neg_integer(), non_neg_integer(), String.t()}
```

# `t`

```elixir
@type t() :: %Docker.Commands.Run{
  cap_add: [String.t()],
  cap_drop: [String.t()],
  command: [String.t()] | nil,
  cpus: String.t() | nil,
  detach: boolean(),
  devices: [String.t()],
  dns: [String.t()],
  entrypoint: String.t() | nil,
  env: [env_pair()],
  env_file: [String.t()],
  extra_args: [String.t()],
  extra_hosts: [{String.t(), String.t()}],
  health_cmd: String.t() | nil,
  health_interval: String.t() | nil,
  health_retries: non_neg_integer() | nil,
  health_timeout: String.t() | nil,
  hostname: String.t() | nil,
  image: String.t(),
  init: boolean(),
  interactive: boolean(),
  ipc: String.t() | nil,
  labels: [env_pair()],
  log_driver: String.t() | nil,
  log_opts: [env_pair()],
  memory: String.t() | nil,
  mounts: [mount_spec()],
  name: String.t() | nil,
  network: String.t() | nil,
  pid: String.t() | nil,
  platform: String.t() | nil,
  ports: [port_mapping()],
  privileged: boolean(),
  read_only: boolean(),
  restart: String.t() | nil,
  rm: boolean(),
  runtime: String.t() | nil,
  shm_size: String.t() | nil,
  tmpfs: [String.t()],
  tty: boolean(),
  user: String.t() | nil,
  volumes: [volume_mapping()],
  workdir: String.t() | nil
}
```

# `volume_mapping`

```elixir
@type volume_mapping() :: {String.t(), String.t(), String.t()}
```

# `cap_add`

Adds a Linux capability.

# `cap_drop`

Drops a Linux capability.

# `command`

```elixir
@spec command(t(), String.t() | [String.t()]) :: t()
```

Sets the command to run inside the container.

# `cpus`

Sets the CPU limit.

# `detach`

Runs in detached mode.

# `device`

Adds a device.

# `dns`

Adds a DNS server.

# `entrypoint`

Sets the entrypoint.

# `env`

Adds an environment variable.

# `env_file`

Adds an env file.

# `extra_host`

Adds an extra host mapping.

# `health_cmd`

Sets the health check command.

# `health_interval`

Sets the health check interval.

# `health_retries`

Sets the health check retries.

# `health_timeout`

Sets the health check timeout.

# `hostname`

Sets the hostname.

# `init_flag`

Runs an init process inside the container.

# `interactive`

Enables interactive mode.

# `ipc`

Sets the IPC namespace.

# `label`

Adds a label.

# `log_driver`

Sets the logging driver.

# `log_opt`

Adds a log option.

# `memory`

Sets the memory limit.

# `mount`

```elixir
@spec mount(t(), String.t(), String.t(), String.t(), keyword()) :: t()
```

Adds a mount specification.

# `name`

Sets the container name.

# `network`

Sets the network.

# `new`

```elixir
@spec new(String.t()) :: t()
```

Creates a new run command for the given image.

# `pid`

Sets the PID namespace.

# `platform`

Sets the platform.

# `port`

```elixir
@spec port(t(), non_neg_integer(), non_neg_integer(), keyword()) :: t()
```

Adds a port mapping.

# `privileged`

Runs in privileged mode.

# `raw`

```elixir
@spec raw(t(), [String.t()]) :: t()
```

Adds raw extra arguments to the command.

# `raw`

```elixir
@spec raw(t(), String.t(), String.t()) :: t()
```

Adds a raw flag and value to the command.

# `read_only`

Mounts the root filesystem as read-only.

# `restart`

Sets the restart policy.

# `rm`

Removes the container on exit.

# `runtime`

Sets the runtime.

# `shm_size`

Sets the shared memory size.

# `tmpfs`

Adds a tmpfs mount.

# `tty`

Allocates a pseudo-TTY.

# `user`

Sets the user.

# `volume`

```elixir
@spec volume(t(), String.t(), String.t(), keyword()) :: t()
```

Adds a volume mount.

# `workdir`

Sets the working directory inside the container.

---

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