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
Returns a File representing the container serialized to a tarball.
§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
Returns a File representing the container serialized to a tarball.
§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 default_args(&self) -> Result<Vec<String>, DaggerError>
pub async fn default_args(&self) -> Result<Vec<String>, DaggerError>
Retrieves default arguments for future commands.
Sourcepub fn directory(&self, path: impl Into<String>) -> Directory
pub fn directory(&self, path: impl Into<String>) -> Directory
Retrieves a directory at the given path. 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
Retrieves a directory at the given path. 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>
Retrieves entrypoint to be prepended to the arguments of all commands.
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 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 set.
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 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
Initializes this container from a pulled base image.
§Arguments
address
- Image’s address from its registry.
Formatted as [host]/[user]/[repo]:[tag] (e.g., “docker.io/dagger/dagger:main”).
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>
Publishes this container as a new image to the specified address. Publish returns a fully qualified ref. It can also publish platform variants.
§Arguments
address
- Registry’s address to publish the image to.
Formatted as [host]/[user]/[repo]:[tag] (e.g. “docker.io/dagger/dagger:main”).
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>
Publishes this container as a new image to the specified address. Publish returns a fully qualified ref. It can also publish platform variants.
§Arguments
address
- Registry’s address to publish the image to.
Formatted as [host]/[user]/[repo]:[tag] (e.g. “docker.io/dagger/dagger:main”).
opt
- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn rootfs(&self) -> Directory
pub fn rootfs(&self) -> Directory
Retrieves this container’s root filesystem. Mounts are not included.
Sourcepub async fn stderr(&self) -> Result<String, DaggerError>
pub async fn stderr(&self) -> Result<String, DaggerError>
The error stream of the last executed command. Returns an error if no command was set.
Sourcepub async fn stdout(&self) -> Result<String, DaggerError>
pub async fn stdout(&self) -> Result<String, DaggerError>
The output stream of the last executed command. Returns an error if no command was set.
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.
§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
Retrieves this container plus a directory written at the given path.
§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
Retrieves this container plus a directory written at the given path.
§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
Retrieves this container but with a different command entrypoint.
§Arguments
args
- Entrypoint to use for future executions (e.g., [“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
Retrieves this container but with a different command entrypoint.
§Arguments
args
- Entrypoint to use for future executions (e.g., [“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
Retrieves this container plus the given environment variable.
§Arguments
name
- The name of the environment variable (e.g., “HOST”).value
- The 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
Retrieves this container plus the given environment variable.
§Arguments
name
- The name of the environment variable (e.g., “HOST”).value
- The 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
Retrieves this container after executing the specified command inside it.
§Arguments
args
- Command to run instead of the container’s default command (e.g., [“go”, “run”, “main.go”]).
If empty, the container’s default command is used.
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
Retrieves this container after executing the specified command inside it.
§Arguments
args
- Command to run instead of the container’s default command (e.g., [“go”, “run”, “main.go”]).
If empty, the container’s default command is used.
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. 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 exposeopt
- 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. 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 exposeopt
- 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
Retrieves this container plus the contents of the given file copied to the given path.
§Arguments
path
- Location of the copied file (e.g., “/tmp/file.txt”).source
- Identifier of the file to copy.opt
- 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
Retrieves this container plus the contents of the given file copied to the given path.
§Arguments
path
- Location of the copied file (e.g., “/tmp/file.txt”).source
- Identifier of the file to copy.opt
- 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
Retrieves this container plus a new file written at the given path.
§Arguments
path
- Location of the written file (e.g., “/tmp/file.txt”).contents
- Content of the file to write (e.g., “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
Retrieves this container plus a new file written at the given path.
§Arguments
path
- Location of the written file (e.g., “/tmp/file.txt”).contents
- Content of the file to write (e.g., “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
Retrieves this container with a registry authentication for a given address.
§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.
Sourcepub fn with_rootfs(&self, directory: impl IntoID<DirectoryId>) -> Container
pub fn with_rootfs(&self, directory: impl IntoID<DirectoryId>) -> Container
Retrieves the container with the given directory mounted to /.
§Arguments
directory
- Directory to mount.
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
Retrieves this container plus an env variable containing the given secret.
§Arguments
name
- The name of the secret variable (e.g., “API_SECRET”).secret
- The 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 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.
§Arguments
alias
- A name that can be used to reach the service from the containerservice
- Identifier of the service container
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
Retrieves this container with a different working directory.
§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
Retrieves this container with a different working directory.
§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
Retrieves this container with unset default arguments for future commands.
Sourcepub fn without_directory(&self, path: impl Into<String>) -> Container
pub fn without_directory(&self, path: impl Into<String>) -> Container
Retrieves this container with the directory at the given path removed.
§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
Retrieves this container with the directory at the given path removed.
§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
Retrieves this container with an unset command 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
Retrieves this container with an unset command 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
Retrieves this container with the files at the given paths removed.
§Arguments
paths
- Location of the files to remove (e.g., [“/file.txt”]).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
Retrieves this container with the files at the given paths removed.
§Arguments
paths
- Location of the files to remove (e.g., [“/file.txt”]).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
Retrieves this container with an unset 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.