#mkdir and cp commands

1 messages · Page 1 of 1 (latest)

elfin belfry
#

Hello, how is the dagger way to run mkdir and cp commands in the container? I tried with with_exec but in the next actions it does not persist

gritty widget
#

Do you mean:

package main

import (
    "context"
    "os"

    "dagger.io/dagger"
    "github.com/wingyplus/must"
)

func main() {
    client := must.Must(dagger.Connect(context.Background(), dagger.WithLogOutput(os.Stderr)))
    defer client.Close()
    client.
        Container().
        From("ubuntu").
        WithExec([]string{"mkdir", "hello"}).
        WithExec([]string{"ls", "-la"}).
        Stdout(context.Background())
}
outer wedge
# elfin belfry Hello, how is the dagger way to run mkdir and cp commands in the container? I tr...

The key, as shown in the golang example above, is to actually trigger the execution of the pipeline by using a "leaf" or "finalizing" operation like stdout or exit_code. The pipelines are lazy and only execute when you trigger them with an operation like that. There is a proposal to use sync as a way to force execution up to a point: https://github.com/dagger/dagger/issues/5065

GitHub

Problem Developers are often confused by a property of the engine called "laziness": pipelines are executed at the latest possible moment, to maximize performance. Sometimes developers wa...