Struct dagger_sdk::Container
source · pub struct Container {
pub proc: Arc<Child>,
pub selection: Selection,
pub conn: ConnectParams,
}Fields§
§proc: Arc<Child>§selection: Selection§conn: ConnectParamsImplementations§
source§impl Container
impl Container
sourcepub fn build(&self, context: DirectoryId) -> Container
pub fn build(&self, context: DirectoryId) -> Container
Initializes this container from a Dockerfile build, using the context, a dockerfile file path and some additional buildArgs.
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: DirectoryId,
opts: ContainerBuildOpts<'a>
) -> Container
pub fn build_opts<'a>( &self, context: DirectoryId, opts: ContainerBuildOpts<'a> ) -> Container
Initializes this container from a Dockerfile build, using the context, a dockerfile file path and some additional buildArgs.
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>>
pub async fn default_args(&self) -> Result<Vec<String>>
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.
sourcepub async fn entrypoint(&self) -> Result<Vec<String>>
pub async fn entrypoint(&self) -> Result<Vec<String>>
Retrieves entrypoint to be prepended to the arguments of all commands.
sourcepub async fn env_variable(&self, name: impl Into<String>) -> Result<String>
pub async fn env_variable(&self, name: impl Into<String>) -> Result<String>
Retrieves the value of the specified environment variable.
sourcepub fn env_variables(&self) -> Vec<EnvVariable>
pub fn env_variables(&self) -> Vec<EnvVariable>
Retrieves the list of environment variables passed to commands.
sourcepub fn exec(&self) -> Container
pub fn exec(&self) -> Container
Retrieves this container after executing the specified command inside it.
Arguments
opt- optional argument, see inner type for documentation, use_opts to use
sourcepub fn exec_opts<'a>(&self, opts: ContainerExecOpts<'a>) -> Container
pub fn exec_opts<'a>(&self, opts: ContainerExecOpts<'a>) -> Container
Retrieves this container after executing the specified command inside it.
Arguments
opt- optional argument, see inner type for documentation, use_opts to use
sourcepub async fn exit_code(&self) -> Result<isize>
pub async fn exit_code(&self) -> Result<isize>
Exit code of the last executed command. Zero means success. Null if no command has been executed.
sourcepub async fn export(&self, path: impl Into<String>) -> Result<bool>
pub async fn export(&self, path: impl Into<String>) -> Result<bool>
Writes the container as an OCI tarball to the destination file path on the host for the specified platformVariants. Return true on success.
Arguments
path- Host’s destination path. 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<bool>
pub async fn export_opts( &self, path: impl Into<String>, opts: ContainerExportOpts ) -> Result<bool>
Writes the container as an OCI tarball to the destination file path on the host for the specified platformVariants. Return true on success.
Arguments
path- Host’s destination path. 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 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.
sourcepub fn from(&self, address: impl Into<String>) -> Container
pub fn from(&self, address: impl Into<String>) -> Container
Initializes this container from the base image published at the given address.
Arguments
address- Image’s address from its registry. Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).
sourcepub fn fs(&self) -> Directory
pub fn fs(&self) -> Directory
Retrieves this container’s root filesystem. Mounts are not included.
sourcepub async fn id(&self) -> Result<ContainerId>
pub async fn id(&self) -> Result<ContainerId>
A unique identifier for this container.
sourcepub async fn label(&self, name: impl Into<String>) -> Result<String>
pub async fn label(&self, name: impl Into<String>) -> Result<String>
Retrieves the value of the specified label.
sourcepub async fn mounts(&self) -> Result<Vec<String>>
pub async fn mounts(&self) -> Result<Vec<String>>
Retrieves the list of paths where a directory is mounted.
sourcepub fn pipeline(&self, name: impl Into<String>) -> Container
pub fn pipeline(&self, name: impl Into<String>) -> Container
Creates a named sub-pipeline
Arguments
opt- optional argument, see inner type for documentation, use_opts to use
sourcepub fn pipeline_opts<'a>(
&self,
name: impl Into<String>,
opts: ContainerPipelineOpts<'a>
) -> Container
pub fn pipeline_opts<'a>( &self, name: impl Into<String>, opts: ContainerPipelineOpts<'a> ) -> Container
Creates a named sub-pipeline
Arguments
opt- optional argument, see inner type for documentation, use_opts to use
sourcepub async fn platform(&self) -> Result<Platform>
pub async fn platform(&self) -> Result<Platform>
The platform this container executes and publishes as.
sourcepub async fn publish(&self, address: impl Into<String>) -> Result<String>
pub async fn publish(&self, address: impl Into<String>) -> Result<String>
Publishes this container as a new image to the specified address, for the platformVariants, returning a fully qualified ref.
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>
pub async fn publish_opts( &self, address: impl Into<String>, opts: ContainerPublishOpts ) -> Result<String>
Publishes this container as a new image to the specified address, for the platformVariants, returning a fully qualified ref.
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>
pub async fn stderr(&self) -> Result<String>
The error stream of the last executed command. Null if no command has been executed.
sourcepub async fn stdout(&self) -> Result<String>
pub async fn stdout(&self) -> Result<String>
The output stream of the last executed command. Null if no command has been executed.
sourcepub fn with_default_args(&self) -> Container
pub fn with_default_args(&self) -> Container
Configures default arguments for future commands.
Arguments
opt- optional argument, see inner type for documentation, use_opts to use
sourcepub fn with_default_args_opts<'a>(
&self,
opts: ContainerWithDefaultArgsOpts<'a>
) -> Container
pub fn with_default_args_opts<'a>( &self, opts: ContainerWithDefaultArgsOpts<'a> ) -> Container
Configures default arguments for future commands.
Arguments
opt- optional argument, see inner type for documentation, use_opts to use
sourcepub fn with_directory(
&self,
path: impl Into<String>,
directory: DirectoryId
) -> Container
pub fn with_directory( &self, path: impl Into<String>, directory: DirectoryId ) -> Container
Retrieves this container plus a directory written at the given path.
Arguments
opt- optional argument, see inner type for documentation, use_opts to use
sourcepub fn with_directory_opts<'a>(
&self,
path: impl Into<String>,
directory: DirectoryId,
opts: ContainerWithDirectoryOpts<'a>
) -> Container
pub fn with_directory_opts<'a>( &self, path: impl Into<String>, directory: DirectoryId, opts: ContainerWithDirectoryOpts<'a> ) -> Container
Retrieves this container plus a directory written at the given path.
Arguments
opt- 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.
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.
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.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.opt- optional argument, see inner type for documentation, use_opts to use
sourcepub fn with_fs(&self, id: DirectoryId) -> Container
pub fn with_fs(&self, id: DirectoryId) -> Container
Initializes this container from this DirectoryID.
sourcepub fn with_file(&self, path: impl Into<String>, source: FileId) -> Container
pub fn with_file(&self, path: impl Into<String>, source: FileId) -> Container
Retrieves this container plus the contents of the given file copied to the given path.
Arguments
opt- optional argument, see inner type for documentation, use_opts to use
sourcepub fn with_file_opts(
&self,
path: impl Into<String>,
source: FileId,
opts: ContainerWithFileOpts
) -> Container
pub fn with_file_opts( &self, path: impl Into<String>, source: FileId, opts: ContainerWithFileOpts ) -> Container
Retrieves this container plus the contents of the given file copied to the given path.
Arguments
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.
sourcepub fn with_mounted_cache(
&self,
path: impl Into<String>,
cache: CacheId
) -> Container
pub fn with_mounted_cache( &self, path: impl Into<String>, cache: CacheId ) -> Container
Retrieves this container plus a cache volume mounted at the given path.
Arguments
path- Path to mount the cache volume at.cache- ID of the cache to mount.opt- optional argument, see inner type for documentation, use_opts to use
sourcepub fn with_mounted_cache_opts(
&self,
path: impl Into<String>,
cache: CacheId,
opts: ContainerWithMountedCacheOpts
) -> Container
pub fn with_mounted_cache_opts( &self, path: impl Into<String>, cache: CacheId, opts: ContainerWithMountedCacheOpts ) -> Container
Retrieves this container plus a cache volume mounted at the given path.
Arguments
path- Path to mount the cache volume at.cache- ID of the cache 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: DirectoryId
) -> Container
pub fn with_mounted_directory( &self, path: impl Into<String>, source: DirectoryId ) -> Container
Retrieves this container plus a directory mounted at the given path.
sourcepub fn with_mounted_file(
&self,
path: impl Into<String>,
source: FileId
) -> Container
pub fn with_mounted_file( &self, path: impl Into<String>, source: FileId ) -> Container
Retrieves this container plus a file mounted at the given path.
sourcepub fn with_mounted_secret(
&self,
path: impl Into<String>,
source: SecretId
) -> Container
pub fn with_mounted_secret( &self, path: impl Into<String>, source: SecretId ) -> Container
Retrieves this container plus a secret mounted into a file at the given path.
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.
sourcepub fn with_new_file(&self, path: impl Into<String>) -> Container
pub fn with_new_file(&self, path: impl Into<String>) -> Container
Retrieves this container plus a new file written at the given path.
Arguments
opt- optional argument, see inner type for documentation, use_opts to use
sourcepub fn with_new_file_opts<'a>(
&self,
path: impl Into<String>,
opts: ContainerWithNewFileOpts<'a>
) -> Container
pub fn with_new_file_opts<'a>( &self, path: impl Into<String>, opts: ContainerWithNewFileOpts<'a> ) -> Container
Retrieves this container plus a new file written at the given path.
Arguments
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: SecretId
) -> Container
pub fn with_registry_auth( &self, address: impl Into<String>, username: impl Into<String>, secret: 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, id: DirectoryId) -> Container
pub fn with_rootfs(&self, id: DirectoryId) -> Container
Initializes this container from this DirectoryID.
sourcepub fn with_secret_variable(
&self,
name: impl Into<String>,
secret: SecretId
) -> Container
pub fn with_secret_variable( &self, name: impl Into<String>, secret: SecretId ) -> Container
Retrieves this container plus an env variable containing the given secret.
sourcepub fn with_unix_socket(
&self,
path: impl Into<String>,
source: SocketId
) -> Container
pub fn with_unix_socket( &self, path: impl Into<String>, source: SocketId ) -> Container
Retrieves this container plus a socket forwarded to the given Unix socket path.
sourcepub fn with_user(&self, name: impl Into<String>) -> Container
pub fn with_user(&self, name: impl Into<String>) -> Container
Retrieves this containers with a different command user.
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.
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.
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.
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.
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_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.