dagger/dsl/container

Types

pub type Opts {
  Opts(
    platform: option.Option(String),
    args: option.Option(List(String)),
    use_entrypoint: option.Option(Bool),
    experimental_privileged_nesting: option.Option(Bool),
    insecure_root_capabilities: option.Option(Bool),
    expand: option.Option(Bool),
    no_init: option.Option(Bool),
    platform_variants: option.Option(List(types.Container)),
    forced_compression: option.Option(types.ImageLayerCompression),
    media_types: option.Option(types.ImageMediaTypes),
    expected_type: option.Option(types.ExistsType),
    do_not_follow_symlinks: option.Option(Bool),
    tag: option.Option(String),
    cmd: option.Option(List(String)),
    random: option.Option(Bool),
    ports: option.Option(List(types.PortForward)),
    exclude: option.Option(List(String)),
    include: option.Option(List(String)),
    gitignore: option.Option(Bool),
    owner: option.Option(String),
    keep_default_args: option.Option(Bool),
    stdin: option.Option(String),
    redirect_stdin: option.Option(String),
    redirect_stdout: option.Option(String),
    redirect_stderr: option.Option(String),
    expect: option.Option(types.ReturnType),
    protocol: option.Option(types.NetworkProtocol),
    description: option.Option(String),
    experimental_skip_healthcheck: option.Option(Bool),
    permissions: option.Option(Int),
    source: option.Option(types.Directory),
    sharing: option.Option(types.CacheSharingMode),
    mode: option.Option(Int),
    size: option.Option(Int),
  )
}

Constructors

Values

pub fn args(opts: Opts, val: List(String)) -> Opts
pub fn as_service(
  parent: types.Container,
  with with_fn: fn(Opts) -> Opts,
) -> types.Service

Turn the container into a Service. Be sure to set any exposed ports before this conversion.

pub fn as_tarball(
  parent: types.Container,
  with with_fn: fn(Opts) -> Opts,
) -> types.File

Package the container state as an OCI image, and return it as a tar archive

pub fn cmd(opts: Opts, val: List(String)) -> Opts
pub fn combined_output(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

The combined buffered standard output and standard error stream of the last executed command Returns an error if no command was executed

pub fn container(
  with with_fn: fn(Opts) -> Opts,
) -> types.Container
pub fn default_args(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(List(String), types.QueryError)) -> a,
) -> a

Return the container’s default arguments.

pub fn description(opts: Opts, val: String) -> Opts
pub fn directory(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Directory

Retrieve a directory from the container’s root filesystem Mounts are included.

pub fn do_not_follow_symlinks(opts: Opts, val: Bool) -> Opts
pub fn entrypoint(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(List(String), types.QueryError)) -> a,
) -> a

Return the container’s OCI entrypoint.

pub fn env_variable(
  parent: types.Container,
  name name: String,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

Retrieves the value of the specified environment variable.

pub fn env_variables(
  parent: types.Container,
  select select: fn(types.EnvVariable) -> List(types.Field),
  client client: types.Client,
  then handler: fn(
    Result(List(types.EnvVariable), types.QueryError),
  ) -> a,
) -> a

Retrieves the list of environment variables passed to commands.

pub fn exclude(opts: Opts, val: List(String)) -> Opts
pub fn exists(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
  client client: types.Client,
  then handler: fn(Result(Bool, types.QueryError)) -> a,
) -> a

check if a file or directory exists

pub fn exit_code(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(Int, types.QueryError)) -> a,
) -> a

The exit code of the last executed command Returns an error if no command was executed

pub fn expand(opts: Opts, val: Bool) -> Opts
pub fn expect(opts: Opts, val: types.ReturnType) -> Opts
pub fn expected_type(opts: Opts, val: types.ExistsType) -> Opts
pub fn experimental_privileged_nesting(
  opts: Opts,
  val: Bool,
) -> Opts
pub fn experimental_skip_healthcheck(
  opts: Opts,
  val: Bool,
) -> Opts
pub fn experimental_with_all_g_p_us(
  parent: types.Container,
) -> types.Container

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.

pub fn experimental_with_g_p_u(
  parent: types.Container,
  devices devices: List(String),
) -> types.Container

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.

pub fn export(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

Writes the container as an OCI tarball to the destination file path on the host. It can also export platform variants.

pub fn export_image(
  parent: types.Container,
  name name: String,
  with with_fn: fn(Opts) -> Opts,
  client client: types.Client,
  then handler: fn(Result(Nil, types.QueryError)) -> a,
) -> a

Exports the container as an image to the host’s container image store.

pub fn exposed_ports(
  parent: types.Container,
  select select: fn(types.Port) -> List(types.Field),
  client client: types.Client,
  then handler: fn(Result(List(types.Port), types.QueryError)) -> a,
) -> a

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

pub fn file(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.File

Retrieves a file at the given path. Mounts are included.

pub fn forced_compression(
  opts: Opts,
  val: types.ImageLayerCompression,
) -> Opts
pub fn from(
  parent: types.Container,
  address address: String,
) -> types.Container

Download a container image, and apply it to the container state. All previous state will be lost.

pub fn gitignore(opts: Opts, val: Bool) -> Opts
pub fn id(parent: types.Container) -> types.Container

A unique identifier for this Container.

pub fn image_ref(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

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

pub fn import_(
  parent: types.Container,
  source source: types.File,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Reads the container from an OCI tarball.

pub fn include(opts: Opts, val: List(String)) -> Opts
pub fn insecure_root_capabilities(opts: Opts, val: Bool) -> Opts
pub fn keep_default_args(opts: Opts, val: Bool) -> Opts
pub fn label(
  parent: types.Container,
  name name: String,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

Retrieves the value of the specified label.

pub fn labels(
  parent: types.Container,
  select select: fn(types.Label) -> List(types.Field),
  client client: types.Client,
  then handler: fn(Result(List(types.Label), types.QueryError)) -> a,
) -> a

Retrieves the list of labels passed to container.

pub fn media_types(
  opts: Opts,
  val: types.ImageMediaTypes,
) -> Opts
pub fn mode(opts: Opts, val: Int) -> Opts
pub fn mounts(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(List(String), types.QueryError)) -> a,
) -> a

Retrieves the list of paths where a directory is mounted.

pub fn no_init(opts: Opts, val: Bool) -> Opts
pub fn none(opts: Opts) -> Opts
pub fn opt_platform(opts: Opts, val: String) -> Opts
pub fn owner(opts: Opts, val: String) -> Opts
pub fn permissions(opts: Opts, val: Int) -> Opts
pub fn platform(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

The platform this container executes and publishes as.

pub fn platform_variants(
  opts: Opts,
  val: List(types.Container),
) -> Opts
pub fn ports(opts: Opts, val: List(types.PortForward)) -> Opts
pub fn protocol(opts: Opts, val: types.NetworkProtocol) -> Opts
pub fn publish(
  parent: types.Container,
  address address: String,
  with with_fn: fn(Opts) -> Opts,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

Package the container state as an OCI image, and publish it to a registry Returns the fully qualified address of the published image, with digest

pub fn random(opts: Opts, val: Bool) -> Opts
pub fn redirect_stderr(opts: Opts, val: String) -> Opts
pub fn redirect_stdin(opts: Opts, val: String) -> Opts
pub fn redirect_stdout(opts: Opts, val: String) -> Opts
pub fn rootfs(parent: types.Container) -> types.Directory

Return a snapshot of the container’s root filesystem. The snapshot can be modified then written back using withRootfs. Use that method for filesystem modifications.

pub fn sharing(opts: Opts, val: types.CacheSharingMode) -> Opts
pub fn size(opts: Opts, val: Int) -> Opts
pub fn source(opts: Opts, val: types.Directory) -> Opts
pub fn stat(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Stat

Return file status

pub fn stderr(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

The buffered standard error stream of the last executed command Returns an error if no command was executed

pub fn stdin(opts: Opts, val: String) -> Opts
pub fn stdout(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

The buffered standard output stream of the last executed command Returns an error if no command was executed

pub fn sync(parent: types.Container) -> types.Container

Forces evaluation of the pipeline in the engine. It doesn’t run the default command if no exec has been set.

pub fn tag(opts: Opts, val: String) -> Opts
pub fn terminal(
  parent: types.Container,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

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

pub fn up(
  parent: types.Container,
  with with_fn: fn(Opts) -> Opts,
  client client: types.Client,
  then handler: fn(Result(Nil, types.QueryError)) -> a,
) -> a

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.

pub fn use_entrypoint(opts: Opts, val: Bool) -> Opts
pub fn user(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

Retrieves the user to be set for all commands.

pub fn with_annotation(
  parent: types.Container,
  name name: String,
  value value: String,
) -> types.Container

Retrieves this container plus the given OCI annotation.

pub fn with_default_args(
  parent: types.Container,
  args args: List(String),
) -> types.Container

Configures default arguments for future commands. Like CMD in Dockerfile.

pub fn with_default_terminal_cmd(
  parent: types.Container,
  args args: List(String),
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

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

pub fn with_directory(
  parent: types.Container,
  path path: String,
  source source: types.Directory,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Return a new container snapshot, with a directory added to its filesystem

pub fn with_entrypoint(
  parent: types.Container,
  args args: List(String),
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Set an OCI-style entrypoint. It will be included in the container’s OCI configuration. Note, withExec ignores the entrypoint by default.

pub fn with_env_file_variables(
  parent: types.Container,
  source source: types.EnvFile,
) -> types.Container

Export environment variables from an env-file to the container.

pub fn with_env_variable(
  parent: types.Container,
  name name: String,
  value value: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Set a new environment variable in the container.

pub fn with_error(
  parent: types.Container,
  err err: String,
) -> types.Container

Raise an error.

pub fn with_exec(
  parent: types.Container,
  args args: List(String),
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Execute a command in the container, and return a new snapshot of the container state after execution.

pub fn with_exposed_port(
  parent: types.Container,
  port port: Int,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Expose a network port. Like EXPOSE in Dockerfile (but with healthcheck support) Exposed ports serve two purposes:

  • For health checks and introspection, when running services
  • For setting the EXPOSE OCI field when publishing the container
pub fn with_file(
  parent: types.Container,
  path path: String,
  source source: types.File,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Return a container snapshot with a file added

pub fn with_files(
  parent: types.Container,
  path path: String,
  sources sources: List(types.File),
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

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

pub fn with_label(
  parent: types.Container,
  name name: String,
  value value: String,
) -> types.Container

Retrieves this container plus the given label.

pub fn with_mounted_cache(
  parent: types.Container,
  path path: String,
  cache cache: types.CacheVolume,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

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

pub fn with_mounted_directory(
  parent: types.Container,
  path path: String,
  source source: types.Directory,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

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

pub fn with_mounted_file(
  parent: types.Container,
  path path: String,
  source source: types.File,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

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

pub fn with_mounted_secret(
  parent: types.Container,
  path path: String,
  source source: types.Secret,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

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

pub fn with_mounted_temp(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

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.

pub fn with_new_file(
  parent: types.Container,
  path path: String,
  contents contents: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Return a new container snapshot, with a file added to its filesystem with text content

pub fn with_registry_auth(
  parent: types.Container,
  address address: String,
  username username: String,
  secret secret: types.Secret,
) -> types.Container

Attach credentials for future publishing to a registry. Use in combination with publish

pub fn with_rootfs(
  parent: types.Container,
  directory directory: types.Directory,
) -> types.Container

Change the container’s root filesystem. The previous root filesystem will be lost.

pub fn with_secret_variable(
  parent: types.Container,
  name name: String,
  secret secret: types.Secret,
) -> types.Container

Set a new environment variable, using a secret value

pub fn with_service_binding(
  parent: types.Container,
  alias alias: String,
  service service: types.Service,
) -> types.Container

Establish a runtime dependency from a container to a network 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.

pub fn with_symlink(
  parent: types.Container,
  target target: String,
  link_name link_name: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Return a snapshot with a symlink

pub fn with_unix_socket(
  parent: types.Container,
  path path: String,
  source source: types.Socket,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

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

pub fn with_user(
  parent: types.Container,
  name name: String,
) -> types.Container

Retrieves this container with a different command user.

pub fn with_workdir(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Change the container’s working directory. Like WORKDIR in Dockerfile.

pub fn without_annotation(
  parent: types.Container,
  name name: String,
) -> types.Container

Retrieves this container minus the given OCI annotation.

pub fn without_default_args(
  parent: types.Container,
) -> types.Container

Remove the container’s default arguments.

pub fn without_directory(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Return a new container snapshot, with a directory removed from its filesystem

pub fn without_entrypoint(
  parent: types.Container,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Reset the container’s OCI entrypoint.

pub fn without_env_variable(
  parent: types.Container,
  name name: String,
) -> types.Container

Retrieves this container minus the given environment variable.

pub fn without_exposed_port(
  parent: types.Container,
  port port: Int,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Unexpose a previously exposed port.

pub fn without_file(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

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

pub fn without_files(
  parent: types.Container,
  paths paths: List(String),
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Return a new container spanshot with specified files removed

pub fn without_label(
  parent: types.Container,
  name name: String,
) -> types.Container

Retrieves this container minus the given environment label.

pub fn without_mount(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Retrieves this container after unmounting everything at the given path.

pub fn without_registry_auth(
  parent: types.Container,
  address address: String,
) -> types.Container

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

pub fn without_secret_variable(
  parent: types.Container,
  name name: String,
) -> types.Container

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

pub fn without_unix_socket(
  parent: types.Container,
  path path: String,
  with with_fn: fn(Opts) -> Opts,
) -> types.Container

Retrieves this container with a previously added Unix socket removed.

pub fn without_user(parent: types.Container) -> types.Container

Retrieves this container with an unset command user. Should default to root.

pub fn without_workdir(
  parent: types.Container,
) -> types.Container

Unset the container’s working directory. Should default to “/”.

pub fn workdir(
  parent: types.Container,
  client client: types.Client,
  then handler: fn(Result(String, types.QueryError)) -> a,
) -> a

Retrieves the working directory for all commands.

Search Document