Dagger

Top features of Dagger.

πŸ₯‡ Interactive debugging

With Dagger it’s easy to troubleshoot issue with containers using interactive debugging.

You can open a terminal in the context of a pipeline failure using the --interactive (-i for short) on function calls.

dagger call --interactive hello-world

Alternativelly the Terminal() method can be called anywhere in a pipeline to open a terminal at that point in execution.

func (m *Interactive) Container(ctx context.Context) (string, error) {
    return dag.Container().
        From("alpine:latest").
        Terminal().
        Stdout(ctx)
}

You can also use method chaining for similar behaviour:

dagger call container terminal

πŸ₯ˆ Function chainning

Function chaining enables Dagger function calls to be chainned sequentally to operate on each other’s results.

Given a Dagger module with the following method:

// Builds a container with html2md tool installed
func (m *Test) Container() *dagger.Container {
 return dag.
        Container().
        From("golang:1.23-alpine")
}

Commands can be executed against the container with function chainning:

dagger call container with-exec --args="go","version" stdout

πŸ”— Dagger command execution in containers.

πŸ₯‰ Container-to-host networking

Dagger enables services running on the host machine to be accessible on the containers via the WithServiceBinding() method:

func (m *Binding) Get(
 ctx context.Context,
 // Host service
 svc *dagger.Service,
) (string, error) {
 return dag.
        Container().
  From("alpine").
  WithServiceBinding("local", svc).
        WithExec([]string{"wget", "-O-", "http://local:8080"}).
  Stdout(ctx)
}

The service can then be passed to the Dagger function on the Dagger call command:

 dagger call get --svc tcp://localhost:8080

πŸ”— More on Dagger services

Read more