View Source Dagger.Container (dagger v0.14.0)

An OCI-compatible container, also known as a Docker container.

Summary

Functions

Turn the container into a Service.

Returns a File representing the container serialized to a tarball.

Initializes this container from a Dockerfile build.

Retrieves default arguments for future commands.

Retrieves a directory at the given path.

Retrieves entrypoint to be prepended to the arguments of all commands.

Retrieves the value of the specified environment variable.

Retrieves the list of environment variables passed to commands.

The exit code of the last executed command.

EXPERIMENTAL API! Subject to change/removal at any time.

EXPERIMENTAL API! Subject to change/removal at any time.

Writes the container as an OCI tarball to the destination file path on the host.

Retrieves the list of exposed ports.

Retrieves a file at the given path.

Initializes this container from a pulled base image.

A unique identifier for this Container.

The unique image reference which can only be retrieved immediately after the 'Container.From' call.

Reads the container from an OCI tarball.

Retrieves the value of the specified label.

Retrieves the list of labels passed to container.

Retrieves the list of paths where a directory is mounted.

The platform this container executes and publishes as.

Publishes this container as a new image to the specified address.

Retrieves this container's root filesystem. Mounts are not included.

The error stream of the last executed command.

The output stream of the last executed command.

Forces evaluation of the pipeline in the engine.

Opens an interactive terminal for this container using its configured default terminal command if not overridden by args (or sh as a fallback default).

Starts a Service and creates a tunnel that forwards traffic from the caller's network to that service.

Retrieves the user to be set for all commands.

Retrieves this container plus the given OCI anotation.

Configures default arguments for future commands.

Set the default command to invoke for the container's terminal API.

Retrieves this container plus a directory written at the given path.

Retrieves this container but with a different command entrypoint.

Retrieves this container plus the given environment variable.

Retrieves this container after executing the specified command inside it.

Retrieves this container plus the contents of the given file copied to the given path.

Retrieves this container plus the contents of the given files copied to the given path.

Retrieves this container plus the given label.

Retrieves this container plus a cache volume mounted at the given path.

Retrieves this container plus a directory mounted at the given path.

Retrieves this container plus a file mounted at the given path.

Retrieves this container plus a secret mounted into a file at the given path.

Retrieves this container plus a temporary directory mounted at the given path. Any writes will be ephemeral to a single withExec call; they will not be persisted to subsequent withExecs.

Retrieves this container plus a new file written at the given path.

Retrieves this container with a registry authentication for a given address.

Retrieves the container with the given directory mounted to /.

Retrieves this container plus an env variable containing the given secret.

Establish a runtime dependency on a service.

Retrieves this container plus a socket forwarded to the given Unix socket path.

Retrieves this container with a different command user.

Retrieves this container with a different working directory.

Retrieves this container minus the given OCI annotation.

Retrieves this container with unset default arguments for future commands.

Retrieves this container with the directory at the given path removed.

Retrieves this container with an unset command entrypoint.

Retrieves this container minus the given environment variable.

Retrieves this container with the file at the given path removed.

Retrieves this container with the files at the given paths removed.

Retrieves this container minus the given environment label.

Retrieves this container after unmounting everything at the given path.

Retrieves this container without the registry authentication of a given address.

Retrieves this container minus the given environment variable containing the secret.

Retrieves this container with a previously added Unix socket removed.

Retrieves this container with an unset command user.

Retrieves this container with an unset working directory.

Retrieves the working directory for all commands.

Types

@type t() :: %Dagger.Container{client: term(), query_builder: term()}

Functions

@spec as_service(t()) :: Dagger.Service.t()

Turn the container into a Service.

Be sure to set any exposed ports before this conversion.

Link to this function

as_tarball(container, optional_args \\ [])

View Source
@spec as_tarball(t(),
  platform_variants: [Dagger.ContainerID.t()],
  forced_compression: Dagger.ImageLayerCompression.t() | nil,
  media_types: Dagger.ImageMediaTypes.t() | nil
) :: Dagger.File.t()

Returns a File representing the container serialized to a tarball.

Link to this function

build(container, context, optional_args \\ [])

View Source
@spec build(t(), Dagger.Directory.t(),
  dockerfile: String.t() | nil,
  target: String.t() | nil,
  build_args: [Dagger.BuildArg.t()],
  secrets: [Dagger.SecretID.t()]
) :: t()

Initializes this container from a Dockerfile build.

@spec default_args(t()) :: {:ok, [String.t()]} | {:error, term()}

Retrieves default arguments for future commands.

Link to this function

directory(container, path, optional_args \\ [])

View Source
@spec directory(t(), String.t(), [{:expand, boolean() | nil}]) :: Dagger.Directory.t()

Retrieves a directory at the given path.

Mounts are included.

@spec entrypoint(t()) :: {:ok, [String.t()]} | {:error, term()}

Retrieves entrypoint to be prepended to the arguments of all commands.

Link to this function

env_variable(container, name)

View Source
@spec env_variable(t(), String.t()) :: {:ok, String.t() | nil} | {:error, term()}

Retrieves the value of the specified environment variable.

Link to this function

env_variables(container)

View Source
@spec env_variables(t()) :: {:ok, [Dagger.EnvVariable.t()]} | {:error, term()}

Retrieves the list of environment variables passed to commands.

@spec exit_code(t()) :: {:ok, integer()} | {:error, term()}

The exit code of the last executed command.

Returns an error if no command was set.

Link to this function

experimental_with_all_gpus(container)

View Source
@spec experimental_with_all_gpus(t()) :: t()

EXPERIMENTAL API! Subject to change/removal at any time.

Configures all available GPUs on the host to be accessible to this container.

This currently works for Nvidia devices only.

Link to this function

experimental_with_gpu(container, devices)

View Source
@spec experimental_with_gpu(t(), [String.t()]) :: t()

EXPERIMENTAL API! Subject to change/removal at any time.

Configures the provided list of devices to be accessible to this container.

This currently works for Nvidia devices only.

Link to this function

export(container, path, optional_args \\ [])

View Source
@spec export(t(), String.t(),
  platform_variants: [Dagger.ContainerID.t()],
  forced_compression: Dagger.ImageLayerCompression.t() | nil,
  media_types: Dagger.ImageMediaTypes.t() | nil,
  expand: boolean() | nil
) :: {:ok, String.t()} | {:error, term()}

Writes the container as an OCI tarball to the destination file path on the host.

It can also export platform variants.

Link to this function

exposed_ports(container)

View Source
@spec exposed_ports(t()) :: {:ok, [Dagger.Port.t()]} | {:error, term()}

Retrieves the list of exposed ports.

This includes ports already exposed by the image, even if not explicitly added with dagger.

Link to this function

file(container, path, optional_args \\ [])

View Source
@spec file(t(), String.t(), [{:expand, boolean() | nil}]) :: Dagger.File.t()

Retrieves a file at the given path.

Mounts are included.

Link to this function

from(container, address)

View Source
@spec from(t(), String.t()) :: t()

Initializes this container from a pulled base image.

@spec id(t()) :: {:ok, Dagger.ContainerID.t()} | {:error, term()}

A unique identifier for this Container.

@spec image_ref(t()) :: {:ok, String.t()} | {:error, term()}

The unique image reference which can only be retrieved immediately after the 'Container.From' call.

Link to this function

import(container, source, optional_args \\ [])

View Source
@spec import(t(), Dagger.File.t(), [{:tag, String.t() | nil}]) :: t()

Reads the container from an OCI tarball.

@spec label(t(), String.t()) :: {:ok, String.t() | nil} | {:error, term()}

Retrieves the value of the specified label.

@spec labels(t()) :: {:ok, [Dagger.Label.t()]} | {:error, term()}

Retrieves the list of labels passed to container.

@spec mounts(t()) :: {:ok, [String.t()]} | {:error, term()}

Retrieves the list of paths where a directory is mounted.

@spec platform(t()) :: {:ok, Dagger.Platform.t()} | {:error, term()}

The platform this container executes and publishes as.

Link to this function

publish(container, address, optional_args \\ [])

View Source
@spec publish(t(), String.t(),
  platform_variants: [Dagger.ContainerID.t()],
  forced_compression: Dagger.ImageLayerCompression.t() | nil,
  media_types: Dagger.ImageMediaTypes.t() | nil
) :: {:ok, String.t()} | {:error, term()}

Publishes this container as a new image to the specified address.

Publish returns a fully qualified ref.

It can also publish platform variants.

@spec rootfs(t()) :: Dagger.Directory.t()

Retrieves this container's root filesystem. Mounts are not included.

@spec stderr(t()) :: {:ok, String.t()} | {:error, term()}

The error stream of the last executed command.

Returns an error if no command was set.

@spec stdout(t()) :: {:ok, String.t()} | {:error, term()}

The output stream of the last executed command.

Returns an error if no command was set.

@spec sync(t()) :: {:ok, t()} | {:error, term()}

Forces evaluation of the pipeline in the engine.

It doesn't run the default command if no exec has been set.

Link to this function

terminal(container, optional_args \\ [])

View Source
@spec terminal(t(),
  cmd: [String.t()],
  experimental_privileged_nesting: boolean() | nil,
  insecure_root_capabilities: boolean() | nil
) :: t()

Opens an interactive terminal for this container using its configured default terminal command if not overridden by args (or sh as a fallback default).

Link to this function

up(container, optional_args \\ [])

View Source
@spec up(t(), ports: [Dagger.PortForward.t()], random: boolean() | nil) ::
  :ok | {:error, term()}

Starts a Service and creates a tunnel that forwards traffic from the caller's network to that service.

Be sure to set any exposed ports before calling this api.

@spec user(t()) :: {:ok, String.t()} | {:error, term()}

Retrieves the user to be set for all commands.

Link to this function

with_annotation(container, name, value)

View Source
@spec with_annotation(t(), String.t(), String.t()) :: t()

Retrieves this container plus the given OCI anotation.

Link to this function

with_default_args(container, args)

View Source
@spec with_default_args(t(), [String.t()]) :: t()

Configures default arguments for future commands.

Link to this function

with_default_terminal_cmd(container, args, optional_args \\ [])

View Source
@spec with_default_terminal_cmd(
  t(),
  [String.t()],
  experimental_privileged_nesting: boolean() | nil,
  insecure_root_capabilities: boolean() | nil
) :: t()

Set the default command to invoke for the container's terminal API.

Link to this function

with_directory(container, path, directory, optional_args \\ [])

View Source
@spec with_directory(t(), String.t(), Dagger.Directory.t(),
  exclude: [String.t()],
  include: [String.t()],
  owner: String.t() | nil,
  expand: boolean() | nil
) :: t()

Retrieves this container plus a directory written at the given path.

Link to this function

with_entrypoint(container, args, optional_args \\ [])

View Source
@spec with_entrypoint(t(), [String.t()], [{:keep_default_args, boolean() | nil}]) ::
  t()

Retrieves this container but with a different command entrypoint.

Link to this function

with_env_variable(container, name, value, optional_args \\ [])

View Source
@spec with_env_variable(t(), String.t(), String.t(), [{:expand, boolean() | nil}]) ::
  t()

Retrieves this container plus the given environment variable.

Link to this function

with_exec(container, args, optional_args \\ [])

View Source
@spec with_exec(
  t(),
  [String.t()],
  use_entrypoint: boolean() | nil,
  stdin: String.t() | nil,
  redirect_stdout: String.t() | nil,
  redirect_stderr: String.t() | nil,
  expect: Dagger.ReturnType.t() | nil,
  experimental_privileged_nesting: boolean() | nil,
  insecure_root_capabilities: boolean() | nil,
  expand: boolean() | nil,
  no_init: boolean() | nil
) :: t()

Retrieves this container after executing the specified command inside it.

Link to this function

with_exposed_port(container, port, optional_args \\ [])

View Source
@spec with_exposed_port(t(), integer(),
  protocol: Dagger.NetworkProtocol.t() | nil,
  description: String.t() | nil,
  experimental_skip_healthcheck: boolean() | nil
) :: t()

Expose a network port.

Exposed ports serve two purposes:

  • For health checks and introspection, when running services

  • For setting the EXPOSE OCI field when publishing the container

Link to this function

with_file(container, path, source, optional_args \\ [])

View Source
@spec with_file(t(), String.t(), Dagger.File.t(),
  permissions: integer() | nil,
  owner: String.t() | nil,
  expand: boolean() | nil
) :: t()

Retrieves this container plus the contents of the given file copied to the given path.

Link to this function

with_files(container, path, sources, optional_args \\ [])

View Source
@spec with_files(t(), String.t(), [Dagger.FileID.t()],
  permissions: integer() | nil,
  owner: String.t() | nil,
  expand: boolean() | nil
) :: t()

Retrieves this container plus the contents of the given files copied to the given path.

Link to this function

with_label(container, name, value)

View Source
@spec with_label(t(), String.t(), String.t()) :: t()

Retrieves this container plus the given label.

Link to this function

with_mounted_cache(container, path, cache, optional_args \\ [])

View Source
@spec with_mounted_cache(t(), String.t(), Dagger.CacheVolume.t(),
  source: Dagger.DirectoryID.t() | nil,
  sharing: Dagger.CacheSharingMode.t() | nil,
  owner: String.t() | nil,
  expand: boolean() | nil
) :: t()

Retrieves this container plus a cache volume mounted at the given path.

Link to this function

with_mounted_directory(container, path, source, optional_args \\ [])

View Source
@spec with_mounted_directory(t(), String.t(), Dagger.Directory.t(),
  owner: String.t() | nil,
  expand: boolean() | nil
) :: t()

Retrieves this container plus a directory mounted at the given path.

Link to this function

with_mounted_file(container, path, source, optional_args \\ [])

View Source
@spec with_mounted_file(t(), String.t(), Dagger.File.t(),
  owner: String.t() | nil,
  expand: boolean() | nil
) :: t()

Retrieves this container plus a file mounted at the given path.

Link to this function

with_mounted_secret(container, path, source, optional_args \\ [])

View Source
@spec with_mounted_secret(t(), String.t(), Dagger.Secret.t(),
  owner: String.t() | nil,
  mode: integer() | nil,
  expand: boolean() | nil
) :: t()

Retrieves this container plus a secret mounted into a file at the given path.

Link to this function

with_mounted_temp(container, path, optional_args \\ [])

View Source
@spec with_mounted_temp(t(), String.t(),
  size: integer() | nil,
  expand: boolean() | nil
) :: t()

Retrieves this container plus a temporary directory mounted at the given path. Any writes will be ephemeral to a single withExec call; they will not be persisted to subsequent withExecs.

Link to this function

with_new_file(container, path, contents, optional_args \\ [])

View Source
@spec with_new_file(t(), String.t(), String.t(),
  permissions: integer() | nil,
  owner: String.t() | nil,
  expand: boolean() | nil
) :: t()

Retrieves this container plus a new file written at the given path.

Link to this function

with_registry_auth(container, address, username, secret)

View Source
@spec with_registry_auth(t(), String.t(), String.t(), Dagger.Secret.t()) :: t()

Retrieves this container with a registry authentication for a given address.

Link to this function

with_rootfs(container, directory)

View Source
@spec with_rootfs(t(), Dagger.Directory.t()) :: t()

Retrieves the container with the given directory mounted to /.

Link to this function

with_secret_variable(container, name, secret)

View Source
@spec with_secret_variable(t(), String.t(), Dagger.Secret.t()) :: t()

Retrieves this container plus an env variable containing the given secret.

Link to this function

with_service_binding(container, alias, service)

View Source
@spec with_service_binding(t(), String.t(), Dagger.Service.t()) :: t()

Establish a runtime dependency on a service.

The service will be started automatically when needed and detached when it is no longer needed, executing the default command if none is set.

The service will be reachable from the container via the provided hostname alias.

The service dependency will also convey to any files or directories produced by the container.

Link to this function

with_unix_socket(container, path, source, optional_args \\ [])

View Source
@spec with_unix_socket(t(), String.t(), Dagger.Socket.t(),
  owner: String.t() | nil,
  expand: boolean() | nil
) :: t()

Retrieves this container plus a socket forwarded to the given Unix socket path.

Link to this function

with_user(container, name)

View Source
@spec with_user(t(), String.t()) :: t()

Retrieves this container with a different command user.

Link to this function

with_workdir(container, path, optional_args \\ [])

View Source
@spec with_workdir(t(), String.t(), [{:expand, boolean() | nil}]) :: t()

Retrieves this container with a different working directory.

Link to this function

without_annotation(container, name)

View Source
@spec without_annotation(t(), String.t()) :: t()

Retrieves this container minus the given OCI annotation.

Link to this function

without_default_args(container)

View Source
@spec without_default_args(t()) :: t()

Retrieves this container with unset default arguments for future commands.

Link to this function

without_directory(container, path, optional_args \\ [])

View Source
@spec without_directory(t(), String.t(), [{:expand, boolean() | nil}]) :: t()

Retrieves this container with the directory at the given path removed.

Link to this function

without_entrypoint(container, optional_args \\ [])

View Source
@spec without_entrypoint(t(), [{:keep_default_args, boolean() | nil}]) :: t()

Retrieves this container with an unset command entrypoint.

Link to this function

without_env_variable(container, name)

View Source
@spec without_env_variable(t(), String.t()) :: t()

Retrieves this container minus the given environment variable.

Link to this function

without_exposed_port(container, port, optional_args \\ [])

View Source
@spec without_exposed_port(t(), integer(), [
  {:protocol, Dagger.NetworkProtocol.t() | nil}
]) :: t()

Unexpose a previously exposed port.

Link to this function

without_file(container, path, optional_args \\ [])

View Source
@spec without_file(t(), String.t(), [{:expand, boolean() | nil}]) :: t()

Retrieves this container with the file at the given path removed.

Link to this function

without_files(container, paths, optional_args \\ [])

View Source
@spec without_files(t(), [String.t()], [{:expand, boolean() | nil}]) :: t()

Retrieves this container with the files at the given paths removed.

Link to this function

without_label(container, name)

View Source
@spec without_label(t(), String.t()) :: t()

Retrieves this container minus the given environment label.

Link to this function

without_mount(container, path, optional_args \\ [])

View Source
@spec without_mount(t(), String.t(), [{:expand, boolean() | nil}]) :: t()

Retrieves this container after unmounting everything at the given path.

Link to this function

without_registry_auth(container, address)

View Source
@spec without_registry_auth(t(), String.t()) :: t()

Retrieves this container without the registry authentication of a given address.

Link to this function

without_secret_variable(container, name)

View Source
@spec without_secret_variable(t(), String.t()) :: t()

Retrieves this container minus the given environment variable containing the secret.

Link to this function

without_unix_socket(container, path, optional_args \\ [])

View Source
@spec without_unix_socket(t(), String.t(), [{:expand, boolean() | nil}]) :: t()

Retrieves this container with a previously added Unix socket removed.

@spec without_user(t()) :: t()

Retrieves this container with an unset command user.

Should default to root.

Link to this function

without_workdir(container)

View Source
@spec without_workdir(t()) :: t()

Retrieves this container with an unset working directory.

Should default to "/".

@spec workdir(t()) :: {:ok, String.t()} | {:error, term()}

Retrieves the working directory for all commands.