View Source
Getting Started with dagger
Mix.install([
{:dagger, path: "."}
])
before-start
Before start
You need to install:
dagger
binary, you can download in the Release Page.docker
orpodman
.
And make sure all commands above presents in $PATH
.
connecting-to-dagger
Connecting to Dagger
Currently, we support only 2 modes:
- 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
- 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
Fetching the container and running it
In this section, we will pull Elixir image from hex.pm 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.
client
|> 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()