View Source Dagger.Container (dagger v0.8.7)
An OCI-compatible container, also known as a docker container.
Link to this section Summary
Functions
Initializes this container from a Dockerfile build.
Retrieves default arguments for future commands.
Retrieves a directory at the given path.
Retrieves an endpoint that clients can use to reach this container.
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.
Writes the container as an OCI tarball to the destination file path on the host for the specified platform variants.
Retrieves the list of exposed ports.
Retrieves a file at the given path.
Initializes this container from a pulled base image.
Retrieves a hostname which can be used by clients to reach this container.
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.
Creates a named sub-pipeline
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.
Retrieves the user to be set for all commands.
Configures default arguments for future commands.
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.
Expose a network port.
Retrieves this container plus the contents of the given file copied to the given path.
Indicate that subsequent operations should be featured more prominently in the UI.
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.
Retrieves this container plus a new file written at the given path.
Retrieves this container with a registry authentication for a given address.
Initializes this container from this DirectoryID.
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 environment variable.
Unexpose a previously exposed port.
Indicate that subsequent operations should not be featured more prominently in the UI.
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 with a previously added Unix socket removed.
Retrieves the working directory for all commands.
Link to this section Types
Link to this section Functions
@spec build(t(), Dagger.Directory.t(), keyword()) :: t()
Initializes this container from a Dockerfile build.
required-arguments
Required Arguments
context
- Directory context used by the Dockerfile.
optional-arguments
Optional Arguments
dockerfile
- Path to the Dockerfile to use.
Default: './Dockerfile'.
build_args
- Additional build arguments.target
- Target build stage to build.secrets
- Secrets to pass to the build.
They will be mounted at /run/secrets/[secret-name] in the build container
They can be accessed in the Dockerfile using the "secret" mount type and mount path /run/secrets/[secret-name] e.g. RUN --mount=type=secret,id=my-secret curl url?token=$(cat /run/secrets/my-secret)"
@spec default_args(t()) :: {:ok, [Dagger.String.t()] | nil} | {:error, term()}
Retrieves default arguments for future commands.
@spec directory(t(), Dagger.String.t()) :: Dagger.Directory.t()
Retrieves a directory at the given path.
Mounts are included.
required-arguments
Required Arguments
path
- The path of the directory to retrieve (e.g., "./src").
@spec endpoint( t(), keyword() ) :: {:ok, Dagger.String.t()} | {:error, term()}
Retrieves an endpoint that clients can use to reach this container.
If no port is specified, the first exposed port is used. If none exist an error is returned.
If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.
Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
optional-arguments
Optional Arguments
port
- The exposed port number for the endpointscheme
- Return a URL with the given scheme, eg. http for http://
@spec entrypoint(t()) :: {:ok, [Dagger.String.t()] | nil} | {:error, term()}
Retrieves entrypoint to be prepended to the arguments of all commands.
@spec env_variable(t(), Dagger.String.t()) :: {:ok, Dagger.String.t() | nil} | {:error, term()}
Retrieves the value of the specified environment variable.
required-arguments
Required Arguments
name
- The name of the environment variable to retrieve (e.g., "PATH").
@spec env_variables(t()) :: {:ok, [Dagger.EnvVariable.t()]} | {:error, term()}
Retrieves the list of environment variables passed to commands.
@spec export(t(), Dagger.String.t(), keyword()) :: {:ok, Dagger.Boolean.t()} | {:error, term()}
Writes the container as an OCI tarball to the destination file path on the host for the specified platform variants.
Return true on success. It can also publishes platform variants.
required-arguments
Required Arguments
path
- Host's destination path (e.g., "./tarball"). Path can be relative to the engine's workdir or absolute.
optional-arguments
Optional Arguments
platform_variants
- Identifiers for other platform specific containers. Used for multi-platform image.forced_compression
- Force each layer of the exported image to use the specified compression algorithm. If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.media_types
- Use the specified media types for the exported image's layers. Defaults to OCI, which is largely compatible with most recent container runtimes, but Docker may be needed for older runtimes without OCI support.
@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.
Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
@spec file(t(), Dagger.String.t()) :: Dagger.File.t()
Retrieves a file at the given path.
Mounts are included.
required-arguments
Required Arguments
path
- The path of the file to retrieve (e.g., "./README.md").
@spec from(t(), Dagger.String.t()) :: t()
Initializes this container from a pulled base image.
required-arguments
Required Arguments
address
- Image's address from its registry.
Formatted as [host]/[user]/[repo]:[tag] (e.g., "docker.io/dagger/dagger:main").
@spec hostname(t()) :: {:ok, Dagger.String.t()} | {:error, term()}
Retrieves a hostname which can be used by clients to reach this container.
Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
@spec id(t()) :: {:ok, Dagger.ContainerID.t()} | {:error, term()}
A unique identifier for this container.
@spec image_ref(t()) :: {:ok, Dagger.String.t() | nil} | {:error, term()}
The unique image reference which can only be retrieved immediately after the 'Container.From' call.
@spec import(t(), Dagger.File.t(), keyword()) :: t()
Reads the container from an OCI tarball.
NOTE: this involves unpacking the tarball to an OCI store on the host at $XDG_CACHE_DIR/dagger/oci. This directory can be removed whenever you like.
required-arguments
Required Arguments
source
- File to read the container from.
optional-arguments
Optional Arguments
tag
- Identifies the tag to import from the archive, if the archive bundles multiple tags.
@spec label(t(), Dagger.String.t()) :: {:ok, Dagger.String.t() | nil} | {:error, term()}
Retrieves the value of the specified label.
required-arguments
Required Arguments
name
-
@spec labels(t()) :: {:ok, [Dagger.Label.t()]} | {:error, term()}
Retrieves the list of labels passed to container.
@spec mounts(t()) :: {:ok, [Dagger.String.t()]} | {:error, term()}
Retrieves the list of paths where a directory is mounted.
@spec pipeline(t(), Dagger.String.t(), keyword()) :: t()
Creates a named sub-pipeline
required-arguments
Required Arguments
name
- Pipeline name.
optional-arguments
Optional Arguments
description
- Pipeline description.labels
- Pipeline labels.
@spec platform(t()) :: {:ok, Dagger.Platform.t()} | {:error, term()}
The platform this container executes and publishes as.
@spec publish(t(), Dagger.String.t(), keyword()) :: {:ok, Dagger.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.
required-arguments
Required Arguments
address
- Registry's address to publish the image to.
Formatted as [host]/[user]/[repo]:[tag] (e.g. "docker.io/dagger/dagger:main").
optional-arguments
Optional Arguments
platform_variants
- Identifiers for other platform specific containers. Used for multi-platform image.forced_compression
- Force each layer of the published image to use the specified compression algorithm. If this is unset, then if a layer already has a compressed blob in the engine's cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine's cache, then it will be compressed using Gzip.media_types
- Use the specified media types for the published image's layers. Defaults to OCI, which is largely compatible with most recent registries, but Docker may be needed for older registries without OCI support.
@spec rootfs(t()) :: Dagger.Directory.t()
Retrieves this container's root filesystem. Mounts are not included.
@spec stderr(t()) :: {:ok, Dagger.String.t()} | {:error, term()}
The error stream of the last executed command.
Will execute default command if none is set, or error if there's no default.
@spec stdout(t()) :: {:ok, Dagger.String.t()} | {:error, term()}
The output stream of the last executed command.
Will execute default command if none is set, or error if there's no default.
@spec sync(t()) :: {:ok, Dagger.ContainerID.t()} | {:error, term()}
Forces evaluation of the pipeline in the engine.
It doesn't run the default command if no exec has been set.
@spec user(t()) :: {:ok, Dagger.String.t() | nil} | {:error, term()}
Retrieves the user to be set for all commands.
Configures default arguments for future commands.
optional-arguments
Optional Arguments
args
- Arguments to prepend to future executions (e.g., ["-v", "--no-cache"]).
@spec with_directory(t(), Dagger.String.t(), Dagger.Directory.t(), keyword()) :: t()
Retrieves this container plus a directory written at the given path.
required-arguments
Required Arguments
path
- Location of the written directory (e.g., "/tmp/directory").directory
- Identifier of the directory to write
optional-arguments
Optional Arguments
exclude
- Patterns to exclude in the written directory (e.g., ["node_modules/**", ".gitignore", ".git/"]).include
- Patterns to include in the written directory (e.g., ["*.go", "go.mod", "go.sum"]).owner
- A user:group to set for the directory and its contents.
The user and group can either be an ID (1000:1000) or a name (foo:bar).
If the group is omitted, it defaults to the same as the user.
@spec with_entrypoint(t(), [Dagger.String.t()]) :: t()
Retrieves this container but with a different command entrypoint.
required-arguments
Required Arguments
args
- Entrypoint to use for future executions (e.g., ["go", "run"]).
@spec with_env_variable(t(), Dagger.String.t(), Dagger.String.t(), keyword()) :: t()
Retrieves this container plus the given environment variable.
required-arguments
Required Arguments
name
- The name of the environment variable (e.g., "HOST").value
- The value of the environment variable. (e.g., "localhost").
optional-arguments
Optional Arguments
expand
- Replace ${VAR} or $VAR in the value according to the current environment variables defined in the container (e.g., "/opt/bin:$PATH").
@spec with_exec(t(), [Dagger.String.t()], keyword()) :: t()
Retrieves this container after executing the specified command inside it.
required-arguments
Required Arguments
args
- Command to run instead of the container's default command (e.g., ["run", "main.go"]).
If empty, the container's default command is used.
optional-arguments
Optional Arguments
skip_entrypoint
- If the container has an entrypoint, ignore it for args rather than using it to wrap them.stdin
- Content to write to the command's standard input before closing (e.g., "Hello world").redirect_stdout
- Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").redirect_stderr
- Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").experimental_privileged_nesting
- Provides dagger access to the executed command.
Do not use this option unless you trust the command being executed. The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
insecure_root_capabilities
- Execute the command with all root capabilities. This is similar to running a command with "sudo" or executingdocker run
with the--privileged
flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.
@spec with_exposed_port(t(), Dagger.Int.t(), keyword()) :: 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
Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
required-arguments
Required Arguments
port
- Port number to expose
optional-arguments
Optional Arguments
protocol
- Transport layer network protocoldescription
- Optional port description
@spec with_file(t(), Dagger.String.t(), Dagger.File.t(), keyword()) :: t()
Retrieves this container plus the contents of the given file copied to the given path.
required-arguments
Required Arguments
path
- Location of the copied file (e.g., "/tmp/file.txt").source
- Identifier of the file to copy.
optional-arguments
Optional Arguments
permissions
- Permission given to the copied file (e.g., 0600).
Default: 0644.
owner
- A user:group to set for the file.
The user and group can either be an ID (1000:1000) or a name (foo:bar).
If the group is omitted, it defaults to the same as the user.
Indicate that subsequent operations should be featured more prominently in the UI.
@spec with_label(t(), Dagger.String.t(), Dagger.String.t()) :: t()
Retrieves this container plus the given label.
required-arguments
Required Arguments
name
- The name of the label (e.g., "org.opencontainers.artifact.created").value
- The value of the label (e.g., "2023-01-01T00:00:00Z").
@spec with_mounted_cache(t(), Dagger.String.t(), Dagger.Cache.t(), keyword()) :: t()
Retrieves this container plus a cache volume mounted at the given path.
required-arguments
Required Arguments
path
- Location of the cache directory (e.g., "/cache/node_modules").cache
- Identifier of the cache volume to mount.
optional-arguments
Optional Arguments
source
- Identifier of the directory to use as the cache volume's root.sharing
- Sharing mode of the cache volume.owner
- A user:group to set for the mounted cache directory.
Note that this changes the ownership of the specified mount along with the initial filesystem provided by source (if any). It does not have any effect if/when the cache has already been created.
The user and group can either be an ID (1000:1000) or a name (foo:bar).
If the group is omitted, it defaults to the same as the user.
with_mounted_directory(container, path, source, optional_args \\ [])
View Source@spec with_mounted_directory(t(), Dagger.String.t(), Dagger.Directory.t(), keyword()) :: t()
Retrieves this container plus a directory mounted at the given path.
required-arguments
Required Arguments
path
- Location of the mounted directory (e.g., "/mnt/directory").source
- Identifier of the mounted directory.
optional-arguments
Optional Arguments
owner
- A user:group to set for the mounted directory and its contents.
The user and group can either be an ID (1000:1000) or a name (foo:bar).
If the group is omitted, it defaults to the same as the user.
@spec with_mounted_file(t(), Dagger.String.t(), Dagger.File.t(), keyword()) :: t()
Retrieves this container plus a file mounted at the given path.
required-arguments
Required Arguments
path
- Location of the mounted file (e.g., "/tmp/file.txt").source
- Identifier of the mounted file.
optional-arguments
Optional Arguments
owner
- A user or user:group to set for the mounted file.
The user and group can either be an ID (1000:1000) or a name (foo:bar).
If the group is omitted, it defaults to the same as the user.
@spec with_mounted_secret(t(), Dagger.String.t(), Dagger.Secret.t(), keyword()) :: t()
Retrieves this container plus a secret mounted into a file at the given path.
required-arguments
Required Arguments
path
- Location of the secret file (e.g., "/tmp/secret.txt").source
- Identifier of the secret to mount.
optional-arguments
Optional Arguments
owner
- A user:group to set for the mounted secret.
The user and group can either be an ID (1000:1000) or a name (foo:bar).
If the group is omitted, it defaults to the same as the user.
mode
- Permission given to the mounted secret (e.g., 0600). This option requires an owner to be set to be active.
Default: 0400.
@spec with_mounted_temp(t(), Dagger.String.t()) :: t()
Retrieves this container plus a temporary directory mounted at the given path.
required-arguments
Required Arguments
path
- Location of the temporary directory (e.g., "/tmp/temp_dir").
@spec with_new_file(t(), Dagger.String.t(), keyword()) :: t()
Retrieves this container plus a new file written at the given path.
required-arguments
Required Arguments
path
- Location of the written file (e.g., "/tmp/file.txt").
optional-arguments
Optional Arguments
contents
- Content of the file to write (e.g., "Hello world!").permissions
- Permission given to the written file (e.g., 0600).
Default: 0644.
owner
- A user:group to set for the file.
The user and group can either be an ID (1000:1000) or a name (foo:bar).
If the group is omitted, it defaults to the same as the user.
@spec with_registry_auth(t(), Dagger.String.t(), Dagger.String.t(), Dagger.Secret.t()) :: t()
Retrieves this container with a registry authentication for a given address.
required-arguments
Required Arguments
address
- Registry's address to bind the authentication to. Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).username
- The username of the registry's account (e.g., "Dagger").secret
- The API key, password or token to authenticate to this registry.
@spec with_rootfs(t(), Dagger.Directory.t()) :: t()
Initializes this container from this DirectoryID.
required-arguments
Required Arguments
directory
-
@spec with_secret_variable(t(), Dagger.String.t(), Dagger.Secret.t()) :: t()
Retrieves this container plus an env variable containing the given secret.
required-arguments
Required Arguments
name
- The name of the secret variable (e.g., "API_SECRET").secret
- The identifier of the secret value.
@spec with_service_binding(t(), Dagger.String.t(), 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.
Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
required-arguments
Required Arguments
alias
- A name that can be used to reach the service from the containerservice
- Identifier of the service container
@spec with_unix_socket(t(), Dagger.String.t(), Dagger.Socket.t(), keyword()) :: t()
Retrieves this container plus a socket forwarded to the given Unix socket path.
required-arguments
Required Arguments
path
- Location of the forwarded Unix socket (e.g., "/tmp/socket").source
- Identifier of the socket to forward.
optional-arguments
Optional Arguments
owner
- A user:group to set for the mounted socket.
The user and group can either be an ID (1000:1000) or a name (foo:bar).
If the group is omitted, it defaults to the same as the user.
@spec with_user(t(), Dagger.String.t()) :: t()
Retrieves this container with a different command user.
required-arguments
Required Arguments
name
- The user to set (e.g., "root").
@spec with_workdir(t(), Dagger.String.t()) :: t()
Retrieves this container with a different working directory.
required-arguments
Required Arguments
path
- The path to set as the working directory (e.g., "/app").
@spec without_env_variable(t(), Dagger.String.t()) :: t()
Retrieves this container minus the given environment variable.
required-arguments
Required Arguments
name
- The name of the environment variable (e.g., "HOST").
@spec without_exposed_port(t(), Dagger.Int.t(), keyword()) :: t()
Unexpose a previously exposed port.
Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
required-arguments
Required Arguments
port
- Port number to unexpose
optional-arguments
Optional Arguments
protocol
- Port protocol to unexpose
Indicate that subsequent operations should not be featured more prominently in the UI.
This is the initial state of all containers.
@spec without_label(t(), Dagger.String.t()) :: t()
Retrieves this container minus the given environment label.
required-arguments
Required Arguments
name
- The name of the label to remove (e.g., "org.opencontainers.artifact.created").
@spec without_mount(t(), Dagger.String.t()) :: t()
Retrieves this container after unmounting everything at the given path.
required-arguments
Required Arguments
path
- Location of the cache directory (e.g., "/cache/node_modules").
@spec without_registry_auth(t(), Dagger.String.t()) :: t()
Retrieves this container without the registry authentication of a given address.
required-arguments
Required Arguments
address
- Registry's address to remove the authentication from. Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
@spec without_unix_socket(t(), Dagger.String.t()) :: t()
Retrieves this container with a previously added Unix socket removed.
required-arguments
Required Arguments
path
- Location of the socket to remove (e.g., "/tmp/socket").
@spec workdir(t()) :: {:ok, Dagger.String.t() | nil} | {:error, term()}
Retrieves the working directory for all commands.