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: ConnectParams

Implementations§

source§

impl Container

source

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
source

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
source

pub async fn default_args(&self) -> Result<Vec<String>>

Retrieves default arguments for future commands.

source

pub fn directory(&self, path: impl Into<String>) -> Directory

Retrieves a directory at the given path. Mounts are included.

source

pub async fn entrypoint(&self) -> Result<Vec<String>>

Retrieves entrypoint to be prepended to the arguments of all commands.

source

pub async fn env_variable(&self, name: impl Into<String>) -> Result<String>

Retrieves the value of the specified environment variable.

source

pub fn env_variables(&self) -> Vec<EnvVariable>

Retrieves the list of environment variables passed to commands.

source

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
source

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
source

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.

source

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
source

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
source

pub fn file(&self, path: impl Into<String>) -> File

Retrieves a file at the given path. Mounts are included.

source

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).
source

pub fn fs(&self) -> Directory

Retrieves this container’s root filesystem. Mounts are not included.

source

pub async fn id(&self) -> Result<ContainerId>

A unique identifier for this container.

source

pub async fn label(&self, name: impl Into<String>) -> Result<String>

Retrieves the value of the specified label.

source

pub fn labels(&self) -> Vec<Label>

Retrieves the list of labels passed to container.

source

pub async fn mounts(&self) -> Result<Vec<String>>

Retrieves the list of paths where a directory is mounted.

source

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
source

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
source

pub async fn platform(&self) -> Result<Platform>

The platform this container executes and publishes as.

source

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
source

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
source

pub fn rootfs(&self) -> Directory

Retrieves this container’s root filesystem. Mounts are not included.

source

pub async fn stderr(&self) -> Result<String>

The error stream of the last executed command. Null if no command has been executed.

source

pub async fn stdout(&self) -> Result<String>

The output stream of the last executed command. Null if no command has been executed.

source

pub async fn user(&self) -> Result<String>

Retrieves the user to be set for all commands.

source

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
source

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
source

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
source

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
source

pub fn with_entrypoint(&self, args: Vec<impl Into<String>>) -> Container

Retrieves this container but with a different command entrypoint.

source

pub fn with_env_variable( &self, name: impl Into<String>, value: impl Into<String> ) -> Container

Retrieves this container plus the given environment variable.

source

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
source

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
source

pub fn with_fs(&self, id: DirectoryId) -> Container

Initializes this container from this DirectoryID.

source

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
source

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
source

pub fn with_label( &self, name: impl Into<String>, value: impl Into<String> ) -> Container

Retrieves this container plus the given label.

source

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
source

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
source

pub fn with_mounted_directory( &self, path: impl Into<String>, source: DirectoryId ) -> Container

Retrieves this container plus a directory mounted at the given path.

source

pub fn with_mounted_file( &self, path: impl Into<String>, source: FileId ) -> Container

Retrieves this container plus a file mounted at the given path.

source

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.

source

pub fn with_mounted_temp(&self, path: impl Into<String>) -> Container

Retrieves this container plus a temporary directory mounted at the given path.

source

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
source

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
source

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.
source

pub fn with_rootfs(&self, id: DirectoryId) -> Container

Initializes this container from this DirectoryID.

source

pub fn with_secret_variable( &self, name: impl Into<String>, secret: SecretId ) -> Container

Retrieves this container plus an env variable containing the given secret.

source

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.

source

pub fn with_user(&self, name: impl Into<String>) -> Container

Retrieves this containers with a different command user.

source

pub fn with_workdir(&self, path: impl Into<String>) -> Container

Retrieves this container with a different working directory.

source

pub fn without_env_variable(&self, name: impl Into<String>) -> Container

Retrieves this container minus the given environment variable.

source

pub fn without_label(&self, name: impl Into<String>) -> Container

Retrieves this container minus the given environment label.

source

pub fn without_mount(&self, path: impl Into<String>) -> Container

Retrieves this container after unmounting everything at the given path.

source

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).
source

pub fn without_unix_socket(&self, path: impl Into<String>) -> Container

Retrieves this container with a previously added Unix socket removed.

source

pub async fn workdir(&self) -> Result<String>

Retrieves the working directory for all commands.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more