Docker.Commands.Run (docker_wrapper v0.1.2)

Copy Markdown View Source

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()

Summary

Functions

Adds a Linux capability.

Drops a Linux capability.

Sets the command to run inside the container.

Sets the CPU limit.

Runs in detached mode.

Adds a device.

Adds a DNS server.

Sets the entrypoint.

Adds an environment variable.

Adds an env file.

Adds an extra host mapping.

Sets the health check command.

Sets the health check interval.

Sets the health check retries.

Sets the health check timeout.

Sets the hostname.

Runs an init process inside the container.

Enables interactive mode.

Sets the IPC namespace.

Adds a label.

Sets the logging driver.

Adds a log option.

Sets the memory limit.

Adds a mount specification.

Sets the container name.

Sets the network.

Creates a new run command for the given image.

Sets the PID namespace.

Sets the platform.

Runs in privileged mode.

Adds raw extra arguments to the command.

Adds a raw flag and value to the command.

Mounts the root filesystem as read-only.

Sets the restart policy.

Removes the container on exit.

Sets the runtime.

Sets the shared memory size.

Adds a tmpfs mount.

Allocates a pseudo-TTY.

Sets the user.

Sets the working directory inside the container.

Types

env_pair()

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

mount_spec()

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

port_mapping()

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

t()

@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()

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

Functions

cap_add(cmd, cap)

Adds a Linux capability.

cap_drop(cmd, cap)

Drops a Linux capability.

command(cmd, args)

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

Sets the command to run inside the container.

cpus(cmd, c)

Sets the CPU limit.

detach(cmd)

Runs in detached mode.

device(cmd, d)

Adds a device.

dns(cmd, d)

Adds a DNS server.

entrypoint(cmd, e)

Sets the entrypoint.

env(cmd, key, value)

Adds an environment variable.

env_file(cmd, path)

Adds an env file.

extra_host(cmd, host, ip)

Adds an extra host mapping.

health_cmd(cmd, c)

Sets the health check command.

health_interval(cmd, i)

Sets the health check interval.

health_retries(cmd, r)

Sets the health check retries.

health_timeout(cmd, t)

Sets the health check timeout.

hostname(cmd, h)

Sets the hostname.

init_flag(cmd)

Runs an init process inside the container.

interactive(cmd)

Enables interactive mode.

ipc(cmd, i)

Sets the IPC namespace.

label(cmd, key, value)

Adds a label.

log_driver(cmd, d)

Sets the logging driver.

log_opt(cmd, key, value)

Adds a log option.

memory(cmd, m)

Sets the memory limit.

mount(cmd, type, source, target, opts \\ [])

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

Adds a mount specification.

name(cmd, n)

Sets the container name.

network(cmd, n)

Sets the network.

new(image)

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

Creates a new run command for the given image.

pid(cmd, p)

Sets the PID namespace.

platform(cmd, p)

Sets the platform.

port(cmd, host, container, opts \\ [])

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

Adds a port mapping.

privileged(cmd)

Runs in privileged mode.

raw(cmd, args)

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

Adds raw extra arguments to the command.

raw(cmd, flag, value)

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

Adds a raw flag and value to the command.

read_only(cmd)

Mounts the root filesystem as read-only.

restart(cmd, r)

Sets the restart policy.

rm(cmd)

Removes the container on exit.

runtime(cmd, r)

Sets the runtime.

shm_size(cmd, s)

Sets the shared memory size.

tmpfs(cmd, t)

Adds a tmpfs mount.

tty(cmd)

Allocates a pseudo-TTY.

user(cmd, u)

Sets the user.

volume(cmd, host, container, opts \\ [])

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

Adds a volume mount.

workdir(cmd, w)

Sets the working directory inside the container.