pub struct Container {
pub proc: Option<Arc<DaggerSessionProc>>,
pub selection: Selection,
pub graphql_client: DynGraphQLClient,
}
Fields§
§proc: Option<Arc<DaggerSessionProc>>
§selection: Selection
§graphql_client: DynGraphQLClient
Implementations§
Source§impl Container
impl Container
Sourcepub fn as_service(&self) -> Service
pub fn as_service(&self) -> Service
Turn the container into a Service. Be sure to set any exposed ports before this conversion.
§Arguments
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn as_service_opts<'a>(&self, opts: ContainerAsServiceOpts<'a>) -> Service
pub fn as_service_opts<'a>(&self, opts: ContainerAsServiceOpts<'a>) -> Service
Turn the container into a Service. Be sure to set any exposed ports before this conversion.
§Arguments
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn as_tarball(&self) -> File
pub fn as_tarball(&self) -> File
Package the container state as an OCI image, and return it as a tar archive
§Arguments
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn as_tarball_opts(&self, opts: ContainerAsTarballOpts) -> File
pub fn as_tarball_opts(&self, opts: ContainerAsTarballOpts) -> File
Package the container state as an OCI image, and return it as a tar archive
§Arguments
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn build(&self, context: impl IntoID<DirectoryId>) -> Container
pub fn build(&self, context: impl IntoID<DirectoryId>) -> Container
Initializes this container from a Dockerfile build.
§Arguments
context
- Directory context used by the Dockerfile.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn build_opts<'a>(
&self,
context: impl IntoID<DirectoryId>,
opts: ContainerBuildOpts<'a>,
) -> Container
pub fn build_opts<'a>( &self, context: impl IntoID<DirectoryId>, opts: ContainerBuildOpts<'a>, ) -> Container
Initializes this container from a Dockerfile build.
§Arguments
context
- Directory context used by the Dockerfile.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn combined_output(&self) -> Result<String, DaggerError>
pub async fn combined_output(&self) -> Result<String, DaggerError>
The combined buffered standard output and standard error stream of the last executed command Returns an error if no command was executed
Sourcepub async fn default_args(&self) -> Result<Vec<String>, DaggerError>
pub async fn default_args(&self) -> Result<Vec<String>, DaggerError>
Return the container’s default arguments.
Sourcepub fn directory(&self, path: impl Into<String>) -> Directory
pub fn directory(&self, path: impl Into<String>) -> Directory
Retrieve a directory from the container’s root filesystem Mounts are included.
§Arguments
path
- The path of the directory to retrieve (e.g., “./src”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn directory_opts(
&self,
path: impl Into<String>,
opts: ContainerDirectoryOpts,
) -> Directory
pub fn directory_opts( &self, path: impl Into<String>, opts: ContainerDirectoryOpts, ) -> Directory
Retrieve a directory from the container’s root filesystem Mounts are included.
§Arguments
path
- The path of the directory to retrieve (e.g., “./src”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn entrypoint(&self) -> Result<Vec<String>, DaggerError>
pub async fn entrypoint(&self) -> Result<Vec<String>, DaggerError>
Return the container’s OCI entrypoint.
Sourcepub async fn env_variable(
&self,
name: impl Into<String>,
) -> Result<String, DaggerError>
pub async fn env_variable( &self, name: impl Into<String>, ) -> Result<String, DaggerError>
Retrieves the value of the specified environment variable.
§Arguments
name
- The name of the environment variable to retrieve (e.g., “PATH”).
Sourcepub fn env_variables(&self) -> Vec<EnvVariable>
pub fn env_variables(&self) -> Vec<EnvVariable>
Retrieves the list of environment variables passed to commands.
Sourcepub async fn exists(&self, path: impl Into<String>) -> Result<bool, DaggerError>
pub async fn exists(&self, path: impl Into<String>) -> Result<bool, DaggerError>
check if a file or directory exists
§Arguments
path
- Path to check (e.g., “/file.txt”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn exists_opts(
&self,
path: impl Into<String>,
opts: ContainerExistsOpts,
) -> Result<bool, DaggerError>
pub async fn exists_opts( &self, path: impl Into<String>, opts: ContainerExistsOpts, ) -> Result<bool, DaggerError>
check if a file or directory exists
§Arguments
path
- Path to check (e.g., “/file.txt”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn exit_code(&self) -> Result<isize, DaggerError>
pub async fn exit_code(&self) -> Result<isize, DaggerError>
The exit code of the last executed command Returns an error if no command was executed
Sourcepub fn experimental_with_all_gp_us(&self) -> Container
pub fn experimental_with_all_gp_us(&self) -> 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.
Sourcepub fn experimental_with_gpu(
&self,
devices: Vec<impl Into<String>>,
) -> Container
pub fn experimental_with_gpu( &self, devices: Vec<impl Into<String>>, ) -> 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.
§Arguments
devices
- List of devices to be accessible to this container.
Sourcepub async fn export(
&self,
path: impl Into<String>,
) -> Result<String, DaggerError>
pub async fn export( &self, path: impl Into<String>, ) -> Result<String, DaggerError>
Writes the container as an OCI tarball to the destination file path on the host. It can also export platform variants.
§Arguments
path
- Host’s destination path (e.g., “./tarball”).
Path can be relative to the engine’s workdir or absolute.
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn export_opts(
&self,
path: impl Into<String>,
opts: ContainerExportOpts,
) -> Result<String, DaggerError>
pub async fn export_opts( &self, path: impl Into<String>, opts: ContainerExportOpts, ) -> Result<String, DaggerError>
Writes the container as an OCI tarball to the destination file path on the host. It can also export platform variants.
§Arguments
path
- Host’s destination path (e.g., “./tarball”).
Path can be relative to the engine’s workdir or absolute.
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn export_image(
&self,
name: impl Into<String>,
) -> Result<Void, DaggerError>
pub async fn export_image( &self, name: impl Into<String>, ) -> Result<Void, DaggerError>
Exports the container as an image to the host’s container image store.
§Arguments
name
- Name of image to export to in the host’s storeopt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn export_image_opts(
&self,
name: impl Into<String>,
opts: ContainerExportImageOpts,
) -> Result<Void, DaggerError>
pub async fn export_image_opts( &self, name: impl Into<String>, opts: ContainerExportImageOpts, ) -> Result<Void, DaggerError>
Exports the container as an image to the host’s container image store.
§Arguments
name
- Name of image to export to in the host’s storeopt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn exposed_ports(&self) -> Vec<Port>
pub fn exposed_ports(&self) -> Vec<Port>
Retrieves the list of exposed ports. This includes ports already exposed by the image, even if not explicitly added with dagger.
Sourcepub fn file(&self, path: impl Into<String>) -> File
pub fn file(&self, path: impl Into<String>) -> File
Retrieves a file at the given path. Mounts are included.
§Arguments
path
- The path of the file to retrieve (e.g., “./README.md”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn file_opts(
&self,
path: impl Into<String>,
opts: ContainerFileOpts,
) -> File
pub fn file_opts( &self, path: impl Into<String>, opts: ContainerFileOpts, ) -> File
Retrieves a file at the given path. Mounts are included.
§Arguments
path
- The path of the file to retrieve (e.g., “./README.md”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn from(&self, address: impl Into<String>) -> Container
pub fn from(&self, address: impl Into<String>) -> Container
Download a container image, and apply it to the container state. All previous state will be lost.
§Arguments
address
- Address of the container image to download, in standard OCI ref format. Example:“registry.dagger.io/engine:latest”
Sourcepub async fn id(&self) -> Result<ContainerId, DaggerError>
pub async fn id(&self) -> Result<ContainerId, DaggerError>
A unique identifier for this Container.
Sourcepub async fn image_ref(&self) -> Result<String, DaggerError>
pub async fn image_ref(&self) -> Result<String, DaggerError>
The unique image reference which can only be retrieved immediately after the ‘Container.From’ call.
Sourcepub fn import(&self, source: impl IntoID<FileId>) -> Container
pub fn import(&self, source: impl IntoID<FileId>) -> Container
Reads the container from an OCI tarball.
§Arguments
source
- File to read the container from.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn import_opts<'a>(
&self,
source: impl IntoID<FileId>,
opts: ContainerImportOpts<'a>,
) -> Container
pub fn import_opts<'a>( &self, source: impl IntoID<FileId>, opts: ContainerImportOpts<'a>, ) -> Container
Reads the container from an OCI tarball.
§Arguments
source
- File to read the container from.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn label(
&self,
name: impl Into<String>,
) -> Result<String, DaggerError>
pub async fn label( &self, name: impl Into<String>, ) -> Result<String, DaggerError>
Retrieves the value of the specified label.
§Arguments
name
- The name of the label (e.g., “org.opencontainers.artifact.created”).
Sourcepub async fn mounts(&self) -> Result<Vec<String>, DaggerError>
pub async fn mounts(&self) -> Result<Vec<String>, DaggerError>
Retrieves the list of paths where a directory is mounted.
Sourcepub async fn platform(&self) -> Result<Platform, DaggerError>
pub async fn platform(&self) -> Result<Platform, DaggerError>
The platform this container executes and publishes as.
Sourcepub async fn publish(
&self,
address: impl Into<String>,
) -> Result<String, DaggerError>
pub async fn publish( &self, address: impl Into<String>, ) -> Result<String, DaggerError>
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
§Arguments
address
- The OCI address to publish to
Same format as “docker push”. Example: “registry.example.com/user/repo:tag”
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn publish_opts(
&self,
address: impl Into<String>,
opts: ContainerPublishOpts,
) -> Result<String, DaggerError>
pub async fn publish_opts( &self, address: impl Into<String>, opts: ContainerPublishOpts, ) -> Result<String, DaggerError>
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
§Arguments
address
- The OCI address to publish to
Same format as “docker push”. Example: “registry.example.com/user/repo:tag”
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn rootfs(&self) -> Directory
pub fn rootfs(&self) -> 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.
Sourcepub async fn stderr(&self) -> Result<String, DaggerError>
pub async fn stderr(&self) -> Result<String, DaggerError>
The buffered standard error stream of the last executed command Returns an error if no command was executed
Sourcepub async fn stdout(&self) -> Result<String, DaggerError>
pub async fn stdout(&self) -> Result<String, DaggerError>
The buffered standard output stream of the last executed command Returns an error if no command was executed
Sourcepub async fn sync(&self) -> Result<ContainerId, DaggerError>
pub async fn sync(&self) -> Result<ContainerId, DaggerError>
Forces evaluation of the pipeline in the engine. It doesn’t run the default command if no exec has been set.
Sourcepub fn terminal(&self) -> Container
pub fn terminal(&self) -> 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).
§Arguments
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn terminal_opts<'a>(&self, opts: ContainerTerminalOpts<'a>) -> Container
pub fn terminal_opts<'a>(&self, opts: ContainerTerminalOpts<'a>) -> 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).
§Arguments
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn up(&self) -> Result<Void, DaggerError>
pub async fn up(&self) -> Result<Void, DaggerError>
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.
§Arguments
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn up_opts<'a>(
&self,
opts: ContainerUpOpts<'a>,
) -> Result<Void, DaggerError>
pub async fn up_opts<'a>( &self, opts: ContainerUpOpts<'a>, ) -> Result<Void, DaggerError>
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.
§Arguments
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn user(&self) -> Result<String, DaggerError>
pub async fn user(&self) -> Result<String, DaggerError>
Retrieves the user to be set for all commands.
Sourcepub fn with_annotation(
&self,
name: impl Into<String>,
value: impl Into<String>,
) -> Container
pub fn with_annotation( &self, name: impl Into<String>, value: impl Into<String>, ) -> Container
Retrieves this container plus the given OCI anotation.
§Arguments
name
- The name of the annotation.value
- The value of the annotation.
Sourcepub fn with_default_args(&self, args: Vec<impl Into<String>>) -> Container
pub fn with_default_args(&self, args: Vec<impl Into<String>>) -> Container
Configures default arguments for future commands. Like CMD in Dockerfile.
§Arguments
args
- Arguments to prepend to future executions (e.g., [“-v”, “–no-cache”]).
Sourcepub fn with_default_terminal_cmd(
&self,
args: Vec<impl Into<String>>,
) -> Container
pub fn with_default_terminal_cmd( &self, args: Vec<impl Into<String>>, ) -> Container
Set the default command to invoke for the container’s terminal API.
§Arguments
args
- The args of the command.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_default_terminal_cmd_opts(
&self,
args: Vec<impl Into<String>>,
opts: ContainerWithDefaultTerminalCmdOpts,
) -> Container
pub fn with_default_terminal_cmd_opts( &self, args: Vec<impl Into<String>>, opts: ContainerWithDefaultTerminalCmdOpts, ) -> Container
Set the default command to invoke for the container’s terminal API.
§Arguments
args
- The args of the command.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_directory(
&self,
path: impl Into<String>,
directory: impl IntoID<DirectoryId>,
) -> Container
pub fn with_directory( &self, path: impl Into<String>, directory: impl IntoID<DirectoryId>, ) -> Container
Return a new container snapshot, with a directory added to its filesystem
§Arguments
path
- Location of the written directory (e.g., “/tmp/directory”).directory
- Identifier of the directory to writeopt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_directory_opts<'a>(
&self,
path: impl Into<String>,
directory: impl IntoID<DirectoryId>,
opts: ContainerWithDirectoryOpts<'a>,
) -> Container
pub fn with_directory_opts<'a>( &self, path: impl Into<String>, directory: impl IntoID<DirectoryId>, opts: ContainerWithDirectoryOpts<'a>, ) -> Container
Return a new container snapshot, with a directory added to its filesystem
§Arguments
path
- Location of the written directory (e.g., “/tmp/directory”).directory
- Identifier of the directory to writeopt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_entrypoint(&self, args: Vec<impl Into<String>>) -> Container
pub fn with_entrypoint(&self, args: Vec<impl Into<String>>) -> Container
Set an OCI-style entrypoint. It will be included in the container’s OCI configuration. Note, withExec ignores the entrypoint by default.
§Arguments
args
- Arguments of the entrypoint. Example: [“go”, “run”].opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_entrypoint_opts(
&self,
args: Vec<impl Into<String>>,
opts: ContainerWithEntrypointOpts,
) -> Container
pub fn with_entrypoint_opts( &self, args: Vec<impl Into<String>>, opts: ContainerWithEntrypointOpts, ) -> Container
Set an OCI-style entrypoint. It will be included in the container’s OCI configuration. Note, withExec ignores the entrypoint by default.
§Arguments
args
- Arguments of the entrypoint. Example: [“go”, “run”].opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_env_variable(
&self,
name: impl Into<String>,
value: impl Into<String>,
) -> Container
pub fn with_env_variable( &self, name: impl Into<String>, value: impl Into<String>, ) -> Container
Set a new environment variable in the container.
§Arguments
name
- Name of the environment variable (e.g., “HOST”).value
- Value of the environment variable. (e.g., “localhost”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_env_variable_opts(
&self,
name: impl Into<String>,
value: impl Into<String>,
opts: ContainerWithEnvVariableOpts,
) -> Container
pub fn with_env_variable_opts( &self, name: impl Into<String>, value: impl Into<String>, opts: ContainerWithEnvVariableOpts, ) -> Container
Set a new environment variable in the container.
§Arguments
name
- Name of the environment variable (e.g., “HOST”).value
- Value of the environment variable. (e.g., “localhost”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_exec(&self, args: Vec<impl Into<String>>) -> Container
pub fn with_exec(&self, args: Vec<impl Into<String>>) -> Container
Execute a command in the container, and return a new snapshot of the container state after execution.
§Arguments
args
- Command to execute. Must be valid exec() arguments, not a shell command. Example: [“go”, “run”, “main.go”].
To run a shell command, execute the shell and pass the shell command as argument. Example: [“sh”, “-c”, “ls -l | grep foo”]
Defaults to the container’s default arguments (see “defaultArgs” and “withDefaultArgs”).
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_exec_opts<'a>(
&self,
args: Vec<impl Into<String>>,
opts: ContainerWithExecOpts<'a>,
) -> Container
pub fn with_exec_opts<'a>( &self, args: Vec<impl Into<String>>, opts: ContainerWithExecOpts<'a>, ) -> Container
Execute a command in the container, and return a new snapshot of the container state after execution.
§Arguments
args
- Command to execute. Must be valid exec() arguments, not a shell command. Example: [“go”, “run”, “main.go”].
To run a shell command, execute the shell and pass the shell command as argument. Example: [“sh”, “-c”, “ls -l | grep foo”]
Defaults to the container’s default arguments (see “defaultArgs” and “withDefaultArgs”).
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_exposed_port(&self, port: isize) -> Container
pub fn with_exposed_port(&self, port: isize) -> 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
§Arguments
port
- Port number to expose. Example: 8080opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_exposed_port_opts<'a>(
&self,
port: isize,
opts: ContainerWithExposedPortOpts<'a>,
) -> Container
pub fn with_exposed_port_opts<'a>( &self, port: isize, opts: ContainerWithExposedPortOpts<'a>, ) -> 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
§Arguments
port
- Port number to expose. Example: 8080opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_file(
&self,
path: impl Into<String>,
source: impl IntoID<FileId>,
) -> Container
pub fn with_file( &self, path: impl Into<String>, source: impl IntoID<FileId>, ) -> Container
Return a container snapshot with a file added
§Arguments
path
- Path of the new file. Example: “/path/to/new-file.txt”source
- File to addopt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_file_opts<'a>(
&self,
path: impl Into<String>,
source: impl IntoID<FileId>,
opts: ContainerWithFileOpts<'a>,
) -> Container
pub fn with_file_opts<'a>( &self, path: impl Into<String>, source: impl IntoID<FileId>, opts: ContainerWithFileOpts<'a>, ) -> Container
Return a container snapshot with a file added
§Arguments
path
- Path of the new file. Example: “/path/to/new-file.txt”source
- File to addopt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_files(
&self,
path: impl Into<String>,
sources: Vec<FileId>,
) -> Container
pub fn with_files( &self, path: impl Into<String>, sources: Vec<FileId>, ) -> Container
Retrieves this container plus the contents of the given files copied to the given path.
§Arguments
path
- Location where copied files should be placed (e.g., “/src”).sources
- Identifiers of the files to copy.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_files_opts<'a>(
&self,
path: impl Into<String>,
sources: Vec<FileId>,
opts: ContainerWithFilesOpts<'a>,
) -> Container
pub fn with_files_opts<'a>( &self, path: impl Into<String>, sources: Vec<FileId>, opts: ContainerWithFilesOpts<'a>, ) -> Container
Retrieves this container plus the contents of the given files copied to the given path.
§Arguments
path
- Location where copied files should be placed (e.g., “/src”).sources
- Identifiers of the files to copy.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_label(
&self,
name: impl Into<String>,
value: impl Into<String>,
) -> Container
pub fn with_label( &self, name: impl Into<String>, value: impl Into<String>, ) -> Container
Retrieves this container plus the given label.
§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”).
Sourcepub fn with_mounted_cache(
&self,
path: impl Into<String>,
cache: impl IntoID<CacheVolumeId>,
) -> Container
pub fn with_mounted_cache( &self, path: impl Into<String>, cache: impl IntoID<CacheVolumeId>, ) -> Container
Retrieves this container plus a cache volume mounted at the given path.
§Arguments
path
- Location of the cache directory (e.g., “/root/.npm”).cache
- Identifier of the cache volume to mount.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_mounted_cache_opts<'a>(
&self,
path: impl Into<String>,
cache: impl IntoID<CacheVolumeId>,
opts: ContainerWithMountedCacheOpts<'a>,
) -> Container
pub fn with_mounted_cache_opts<'a>( &self, path: impl Into<String>, cache: impl IntoID<CacheVolumeId>, opts: ContainerWithMountedCacheOpts<'a>, ) -> Container
Retrieves this container plus a cache volume mounted at the given path.
§Arguments
path
- Location of the cache directory (e.g., “/root/.npm”).cache
- Identifier of the cache volume to mount.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_mounted_directory(
&self,
path: impl Into<String>,
source: impl IntoID<DirectoryId>,
) -> Container
pub fn with_mounted_directory( &self, path: impl Into<String>, source: impl IntoID<DirectoryId>, ) -> Container
Retrieves this container plus a directory mounted at the given path.
§Arguments
path
- Location of the mounted directory (e.g., “/mnt/directory”).source
- Identifier of the mounted directory.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_mounted_directory_opts<'a>(
&self,
path: impl Into<String>,
source: impl IntoID<DirectoryId>,
opts: ContainerWithMountedDirectoryOpts<'a>,
) -> Container
pub fn with_mounted_directory_opts<'a>( &self, path: impl Into<String>, source: impl IntoID<DirectoryId>, opts: ContainerWithMountedDirectoryOpts<'a>, ) -> Container
Retrieves this container plus a directory mounted at the given path.
§Arguments
path
- Location of the mounted directory (e.g., “/mnt/directory”).source
- Identifier of the mounted directory.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_mounted_file(
&self,
path: impl Into<String>,
source: impl IntoID<FileId>,
) -> Container
pub fn with_mounted_file( &self, path: impl Into<String>, source: impl IntoID<FileId>, ) -> Container
Retrieves this container plus a file mounted at the given path.
§Arguments
path
- Location of the mounted file (e.g., “/tmp/file.txt”).source
- Identifier of the mounted file.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_mounted_file_opts<'a>(
&self,
path: impl Into<String>,
source: impl IntoID<FileId>,
opts: ContainerWithMountedFileOpts<'a>,
) -> Container
pub fn with_mounted_file_opts<'a>( &self, path: impl Into<String>, source: impl IntoID<FileId>, opts: ContainerWithMountedFileOpts<'a>, ) -> Container
Retrieves this container plus a file mounted at the given path.
§Arguments
path
- Location of the mounted file (e.g., “/tmp/file.txt”).source
- Identifier of the mounted file.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_mounted_secret(
&self,
path: impl Into<String>,
source: impl IntoID<SecretId>,
) -> Container
pub fn with_mounted_secret( &self, path: impl Into<String>, source: impl IntoID<SecretId>, ) -> Container
Retrieves this container plus a secret mounted into a file at the given path.
§Arguments
path
- Location of the secret file (e.g., “/tmp/secret.txt”).source
- Identifier of the secret to mount.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_mounted_secret_opts<'a>(
&self,
path: impl Into<String>,
source: impl IntoID<SecretId>,
opts: ContainerWithMountedSecretOpts<'a>,
) -> Container
pub fn with_mounted_secret_opts<'a>( &self, path: impl Into<String>, source: impl IntoID<SecretId>, opts: ContainerWithMountedSecretOpts<'a>, ) -> Container
Retrieves this container plus a secret mounted into a file at the given path.
§Arguments
path
- Location of the secret file (e.g., “/tmp/secret.txt”).source
- Identifier of the secret to mount.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_mounted_temp(&self, path: impl Into<String>) -> Container
pub fn with_mounted_temp(&self, path: impl Into<String>) -> 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.
§Arguments
path
- Location of the temporary directory (e.g., “/tmp/temp_dir”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_mounted_temp_opts(
&self,
path: impl Into<String>,
opts: ContainerWithMountedTempOpts,
) -> Container
pub fn with_mounted_temp_opts( &self, path: impl Into<String>, opts: ContainerWithMountedTempOpts, ) -> 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.
§Arguments
path
- Location of the temporary directory (e.g., “/tmp/temp_dir”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_new_file(
&self,
path: impl Into<String>,
contents: impl Into<String>,
) -> Container
pub fn with_new_file( &self, path: impl Into<String>, contents: impl Into<String>, ) -> Container
Return a new container snapshot, with a file added to its filesystem with text content
§Arguments
path
- Path of the new file. May be relative or absolute. Example: “README.md” or “/etc/profile”contents
- Contents of the new file. Example: “Hello world!”opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_new_file_opts<'a>(
&self,
path: impl Into<String>,
contents: impl Into<String>,
opts: ContainerWithNewFileOpts<'a>,
) -> Container
pub fn with_new_file_opts<'a>( &self, path: impl Into<String>, contents: impl Into<String>, opts: ContainerWithNewFileOpts<'a>, ) -> Container
Return a new container snapshot, with a file added to its filesystem with text content
§Arguments
path
- Path of the new file. May be relative or absolute. Example: “README.md” or “/etc/profile”contents
- Contents of the new file. Example: “Hello world!”opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_registry_auth(
&self,
address: impl Into<String>,
username: impl Into<String>,
secret: impl IntoID<SecretId>,
) -> Container
pub fn with_registry_auth( &self, address: impl Into<String>, username: impl Into<String>, secret: impl IntoID<SecretId>, ) -> Container
Attach credentials for future publishing to a registry. Use in combination with publish
§Arguments
address
- The image address that needs authentication. Same format as “docker push”. Example: “registry.dagger.io/dagger:latest”username
- The username to authenticate with. Example: “alice”secret
- The API key, password or token to authenticate to this registry
Sourcepub fn with_rootfs(&self, directory: impl IntoID<DirectoryId>) -> Container
pub fn with_rootfs(&self, directory: impl IntoID<DirectoryId>) -> Container
Change the container’s root filesystem. The previous root filesystem will be lost.
§Arguments
directory
- The new root filesystem.
Sourcepub fn with_secret_variable(
&self,
name: impl Into<String>,
secret: impl IntoID<SecretId>,
) -> Container
pub fn with_secret_variable( &self, name: impl Into<String>, secret: impl IntoID<SecretId>, ) -> Container
Set a new environment variable, using a secret value
§Arguments
name
- Name of the secret variable (e.g., “API_SECRET”).secret
- Identifier of the secret value.
Sourcepub fn with_service_binding(
&self,
alias: impl Into<String>,
service: impl IntoID<ServiceId>,
) -> Container
pub fn with_service_binding( &self, alias: impl Into<String>, service: impl IntoID<ServiceId>, ) -> 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.
§Arguments
alias
- Hostname that will resolve to the target service (only accessible from within this container)service
- The target service
Sourcepub fn with_symlink(
&self,
target: impl Into<String>,
link_name: impl Into<String>,
) -> Container
pub fn with_symlink( &self, target: impl Into<String>, link_name: impl Into<String>, ) -> Container
Return a snapshot with a symlink
§Arguments
target
- Location of the file or directory to link to (e.g., “/existing/file”).link_name
- Location where the symbolic link will be created (e.g., “/new-file-link”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_symlink_opts(
&self,
target: impl Into<String>,
link_name: impl Into<String>,
opts: ContainerWithSymlinkOpts,
) -> Container
pub fn with_symlink_opts( &self, target: impl Into<String>, link_name: impl Into<String>, opts: ContainerWithSymlinkOpts, ) -> Container
Return a snapshot with a symlink
§Arguments
target
- Location of the file or directory to link to (e.g., “/existing/file”).link_name
- Location where the symbolic link will be created (e.g., “/new-file-link”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_unix_socket(
&self,
path: impl Into<String>,
source: impl IntoID<SocketId>,
) -> Container
pub fn with_unix_socket( &self, path: impl Into<String>, source: impl IntoID<SocketId>, ) -> Container
Retrieves this container plus a socket forwarded to the given Unix socket path.
§Arguments
path
- Location of the forwarded Unix socket (e.g., “/tmp/socket”).source
- Identifier of the socket to forward.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_unix_socket_opts<'a>(
&self,
path: impl Into<String>,
source: impl IntoID<SocketId>,
opts: ContainerWithUnixSocketOpts<'a>,
) -> Container
pub fn with_unix_socket_opts<'a>( &self, path: impl Into<String>, source: impl IntoID<SocketId>, opts: ContainerWithUnixSocketOpts<'a>, ) -> Container
Retrieves this container plus a socket forwarded to the given Unix socket path.
§Arguments
path
- Location of the forwarded Unix socket (e.g., “/tmp/socket”).source
- Identifier of the socket to forward.opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_user(&self, name: impl Into<String>) -> Container
pub fn with_user(&self, name: impl Into<String>) -> Container
Retrieves this container with a different command user.
§Arguments
name
- The user to set (e.g., “root”).
Sourcepub fn with_workdir(&self, path: impl Into<String>) -> Container
pub fn with_workdir(&self, path: impl Into<String>) -> Container
Change the container’s working directory. Like WORKDIR in Dockerfile.
§Arguments
path
- The path to set as the working directory (e.g., “/app”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_workdir_opts(
&self,
path: impl Into<String>,
opts: ContainerWithWorkdirOpts,
) -> Container
pub fn with_workdir_opts( &self, path: impl Into<String>, opts: ContainerWithWorkdirOpts, ) -> Container
Change the container’s working directory. Like WORKDIR in Dockerfile.
§Arguments
path
- The path to set as the working directory (e.g., “/app”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_annotation(&self, name: impl Into<String>) -> Container
pub fn without_annotation(&self, name: impl Into<String>) -> Container
Retrieves this container minus the given OCI annotation.
§Arguments
name
- The name of the annotation.
Sourcepub fn without_default_args(&self) -> Container
pub fn without_default_args(&self) -> Container
Remove the container’s default arguments.
Sourcepub fn without_directory(&self, path: impl Into<String>) -> Container
pub fn without_directory(&self, path: impl Into<String>) -> Container
Return a new container snapshot, with a directory removed from its filesystem
§Arguments
path
- Location of the directory to remove (e.g., “.github/”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_directory_opts(
&self,
path: impl Into<String>,
opts: ContainerWithoutDirectoryOpts,
) -> Container
pub fn without_directory_opts( &self, path: impl Into<String>, opts: ContainerWithoutDirectoryOpts, ) -> Container
Return a new container snapshot, with a directory removed from its filesystem
§Arguments
path
- Location of the directory to remove (e.g., “.github/”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_entrypoint(&self) -> Container
pub fn without_entrypoint(&self) -> Container
Reset the container’s OCI entrypoint.
§Arguments
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_entrypoint_opts(
&self,
opts: ContainerWithoutEntrypointOpts,
) -> Container
pub fn without_entrypoint_opts( &self, opts: ContainerWithoutEntrypointOpts, ) -> Container
Reset the container’s OCI entrypoint.
§Arguments
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_env_variable(&self, name: impl Into<String>) -> Container
pub fn without_env_variable(&self, name: impl Into<String>) -> Container
Retrieves this container minus the given environment variable.
§Arguments
name
- The name of the environment variable (e.g., “HOST”).
Sourcepub fn without_exposed_port(&self, port: isize) -> Container
pub fn without_exposed_port(&self, port: isize) -> Container
Unexpose a previously exposed port.
§Arguments
port
- Port number to unexposeopt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_exposed_port_opts(
&self,
port: isize,
opts: ContainerWithoutExposedPortOpts,
) -> Container
pub fn without_exposed_port_opts( &self, port: isize, opts: ContainerWithoutExposedPortOpts, ) -> Container
Unexpose a previously exposed port.
§Arguments
port
- Port number to unexposeopt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_file(&self, path: impl Into<String>) -> Container
pub fn without_file(&self, path: impl Into<String>) -> Container
Retrieves this container with the file at the given path removed.
§Arguments
path
- Location of the file to remove (e.g., “/file.txt”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_file_opts(
&self,
path: impl Into<String>,
opts: ContainerWithoutFileOpts,
) -> Container
pub fn without_file_opts( &self, path: impl Into<String>, opts: ContainerWithoutFileOpts, ) -> Container
Retrieves this container with the file at the given path removed.
§Arguments
path
- Location of the file to remove (e.g., “/file.txt”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_files(&self, paths: Vec<impl Into<String>>) -> Container
pub fn without_files(&self, paths: Vec<impl Into<String>>) -> Container
Return a new container spanshot with specified files removed
§Arguments
paths
- Paths of the files to remove. Example: [“foo.txt, “/root/.ssh/config”opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_files_opts(
&self,
paths: Vec<impl Into<String>>,
opts: ContainerWithoutFilesOpts,
) -> Container
pub fn without_files_opts( &self, paths: Vec<impl Into<String>>, opts: ContainerWithoutFilesOpts, ) -> Container
Return a new container spanshot with specified files removed
§Arguments
paths
- Paths of the files to remove. Example: [“foo.txt, “/root/.ssh/config”opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_label(&self, name: impl Into<String>) -> Container
pub fn without_label(&self, name: impl Into<String>) -> Container
Retrieves this container minus the given environment label.
§Arguments
name
- The name of the label to remove (e.g., “org.opencontainers.artifact.created”).
Sourcepub fn without_mount(&self, path: impl Into<String>) -> Container
pub fn without_mount(&self, path: impl Into<String>) -> Container
Retrieves this container after unmounting everything at the given path.
§Arguments
path
- Location of the cache directory (e.g., “/root/.npm”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_mount_opts(
&self,
path: impl Into<String>,
opts: ContainerWithoutMountOpts,
) -> Container
pub fn without_mount_opts( &self, path: impl Into<String>, opts: ContainerWithoutMountOpts, ) -> Container
Retrieves this container after unmounting everything at the given path.
§Arguments
path
- Location of the cache directory (e.g., “/root/.npm”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_registry_auth(&self, address: impl Into<String>) -> Container
pub fn without_registry_auth(&self, address: impl Into<String>) -> Container
Retrieves this container without the registry authentication of a given address.
§Arguments
address
- Registry’s address to remove the authentication from.
Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
Sourcepub fn without_secret_variable(&self, name: impl Into<String>) -> Container
pub fn without_secret_variable(&self, name: impl Into<String>) -> Container
Retrieves this container minus the given environment variable containing the secret.
§Arguments
name
- The name of the environment variable (e.g., “HOST”).
Sourcepub fn without_unix_socket(&self, path: impl Into<String>) -> Container
pub fn without_unix_socket(&self, path: impl Into<String>) -> Container
Retrieves this container with a previously added Unix socket removed.
§Arguments
path
- Location of the socket to remove (e.g., “/tmp/socket”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_unix_socket_opts(
&self,
path: impl Into<String>,
opts: ContainerWithoutUnixSocketOpts,
) -> Container
pub fn without_unix_socket_opts( &self, path: impl Into<String>, opts: ContainerWithoutUnixSocketOpts, ) -> Container
Retrieves this container with a previously added Unix socket removed.
§Arguments
path
- Location of the socket to remove (e.g., “/tmp/socket”).opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn without_user(&self) -> Container
pub fn without_user(&self) -> Container
Retrieves this container with an unset command user. Should default to root.
Sourcepub fn without_workdir(&self) -> Container
pub fn without_workdir(&self) -> Container
Unset the container’s working directory. Should default to “/”.
Sourcepub async fn workdir(&self) -> Result<String, DaggerError>
pub async fn workdir(&self) -> Result<String, DaggerError>
Retrieves the working directory for all commands.