View Source Getting Started with dagger

  {:dagger, path: "."}


Before start

You need to install:

  1. dagger binary, you can download in the Release Page.
  2. docker or podman.

And make sure all commands above presents in $PATH.


Connecting to Dagger

Currently, we support only 2 modes:

  1. Session mode with dagger run. The benefit of running with this mode is it support rich Terminal User Interface (TUI) by set _EXPERIMENTAL_DAGGER_INTERACTIVE_TUI=1
  2. Local CLI mode, this mode will start Dagger session and send a request through the session. This mode need to set _EXPERIMENTAL_DAGGER_CLI_BIN=<path>/<to>/dagger. We'll use this mode in this tutorial.
System.put_env("_EXPERIMENTAL_DAGGER_CLI_BIN", "dagger")

Use Dagger.connect/0 to connect to Dagger server:

{:ok, client} = Dagger.connect()

The result from Dagger.connect/0 is a tuple of :ok with client or :error if it cannot connect.


Fetching the container and running it

In this section, we will pull Elixir image from organization, getting the version from elixir binary and print it to standard output.

After execute the code below, the library will printing out log from Dagger session to the standard output.

|> Dagger.Client.container()
|> Dagger.Container.from("hexpm/elixir:1.14.4-erlang-25.3-debian-buster-20230227-slim")
|> Dagger.Container.with_exec(["elixir", "--version"])
|> Dagger.Container.stdout()