# Getting Started with `dagger`

```elixir
Mix.install([
  {:dagger, path: "."}
])
```

## Before start

You need to install:

1. `dagger` binary, you can download in the [Release Page](https://github.com/dagger/dagger/releases).
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.

```elixir
System.put_env("_EXPERIMENTAL_DAGGER_CLI_BIN", "dagger")
```

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

```elixir
{: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 [hex.pm](https://hub.docker.com/r/hexpm/elixir) 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.

```elixir
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()
```
