#Can I copy artifacts built with Dagger from a container to a host?

1 messages · Page 1 of 1 (latest)

eager mauve
#

Hi.

I am enjoying Dagger with Rust.

As the title says, is it possible to copy artifacts (e.g. binaries) built with Dagger from the container to the host?

I would like to know how to achieve this with Dagger SDK for Rust if possible, but it can be done with other languages as well.

Thank you in advance.
(My English may be poor as I am not a native English speaker, sorry 😢 )

#

Can I copy artifacts built with Dagger from a container to a host?

snow crag
eager mauve
#

Thanks and sorry for the late response.

I was able to achieve this after referring to the page you provided.
Thank you so much!

I was able to achieve this with the following code, so I am posting a sample here as well.

#
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = dagger_sdk::connect().await?;

    let contents = client
        .container()
        .from("alpine:latest")
        .with_directory("/host", client.host().directory("/tmp/sandbox"))
        .with_exec(vec!["/bin/sh", "-c", "`echo foo > /host/bar`"])
        .directory("/host")
        .export("/tmp/sandbox")
        .await?;

    Ok(())
}