View Source Dagger.Container (dagger_ex v0.1.1)
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.
Retrieves this container after executing the specified command inside it.
Exit code of the last executed command. Zero means success.
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 this container's root filesystem. Mounts are not included.
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.
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.
Initializes this container from this DirectoryID.
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.
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 Functions
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].
Retrieves default arguments for future commands.
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").
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://
Retrieves entrypoint to be prepended to the arguments of all commands.
Retrieves the value of the specified environment variable.
required-arguments
Required Arguments
name
- The name of the environment variable to retrieve (e.g., "PATH").
Retrieves the list of environment variables passed to commands.
Retrieves this container after executing the specified command inside it.
optional-arguments
Optional Arguments
args
- Command to run instead of the container's default command (e.g., ["run", "main.go"]).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
- Provide 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.
Exit code of the last executed command. Zero means success.
Will execute default command if none is set, or error if there's no default.
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.
Retrieves the list of exposed ports.
Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
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").
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").
Retrieves this container's root filesystem. Mounts are not included.
Retrieves a hostname which can be used by clients to reach this container.
Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
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.
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.
Retrieves the value of the specified label.
required-arguments
Required Arguments
name
-
Retrieves the list of labels passed to container.
Retrieves the list of paths where a directory is mounted.
Creates a named sub-pipeline
required-arguments
Required Arguments
name
- Pipeline name.
optional-arguments
Optional Arguments
description
- Pipeline description.labels
- Pipeline labels.
The platform this container executes and publishes as.
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.
Retrieves this container's root filesystem. Mounts are not included.
The error stream of the last executed command.
Will execute default command if none is set, or error if there's no default.
The output stream of the last executed command.
Will execute default command if none is set, or error if there's no default.
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"]).
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.
Retrieves this container but with a different command entrypoint.
required-arguments
Required Arguments
args
- Entrypoint to use for future executions (e.g., ["go", "run"]).
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").
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.
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
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.
Initializes this container from this DirectoryID.
required-arguments
Required Arguments
id
-
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").
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 SourceRetrieves 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.
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.
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.
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").
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.
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.
Initializes this container from this DirectoryID.
required-arguments
Required Arguments
id
-
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.
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
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.
Retrieves this container with a different command user.
required-arguments
Required Arguments
name
- The user to set (e.g., "root").
Retrieves this container with a different working directory.
required-arguments
Required Arguments
path
- The path to set as the working directory (e.g., "/app").
Retrieves this container minus the given environment variable.
required-arguments
Required Arguments
name
- The name of the environment variable (e.g., "HOST").
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
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").
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").
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).
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").
Retrieves the working directory for all commands.