Dagger CLI
The Dagger CLI lets you call both the core and extended Dagger API (the core APIs plus the new APIs provided by Dagger Functions) directly from the command-line via the dagger core
and dagger call
commands.
Core Dagger API functions
The dagger core
command lets you call the core Dagger API, without needing to first load a Dagger module. This is useful in some scenarios:
-
You want to use Dagger for simple pipelines that are fully satisfied by the core Dagger API.
dagger core container from --address="cgr.dev/chainguard/wolfi-base" \
with-exec --args="apk","add","go" \
with-directory --path="/src" --directory="https://github.com/golang/example#master" \
with-workdir --path="/src/hello" \
with-exec --args="go","build","-o","hello","." \
file --path="./hello" \
export --path="./hello-from-dagger" -
You want to experiment with Dagger without having to program a Dagger module.
dagger core container from --address=alpine file --path=/etc/os-release contents
-
You want a nice alternative to
docker run
.dagger core container from --address=cgr.dev/chainguard/wolfi-base terminal
Custom Dagger functions
The Dagger API can be extended with Dagger modules. The dagger call
command lets you call Dagger functions from Dagger modules, either remotely or after installing them locally with dagger install
.
-
The
dagger call
command lets you invoke a Dagger Function.Here is an example of using it to call one of the auto-generated Dagger Functions:
dagger call container-echo --string-arg="Welcome to Dagger!" stdout
Here's what you should see:
Welcome to Dagger!
tipWhen using
dagger call
, all names (functions, arguments, struct fields, etc) are converted into a shell-friendly "kebab-case" style. -
Modules don't need to be installed locally. Dagger lets you consume modules from GitHub repositories as well. You can use Dagger Functions from external modules in exactly the same way as you would use them locally.
Here is an example of calling a Dagger Function from an external module, which scans container images for vulnerabilities.
dagger -m github.com/jpadams/daggerverse/trivy@v0.5.0 call scan-image --image-ref=ubuntu:latest
Here's what you should see:
ubuntu:latest (ubuntu 24.04)
============================
Total: 10 (UNKNOWN: 0, LOW: 8, MEDIUM: 2, HIGH: 0, CRITICAL: 0)
... -
The Dagger Functions available in a Dagger module are listed with
dagger functions
.Here is an example of listing Dagger Functions in an external module:
dagger -m github.com/jpadams/daggerverse/trivy@v0.5.0 functions
Here's what you should see:
Name Description
base Return a Container from the official trivy image.
scan-container Scan a Dagger Container.
scan-image Scan an image ref. -
To list all the arguments accepted by a function, add the
--help
suffix at any point in thedagger call
command to obtain context-sensitive help. Here is an example:dagger -m github.com/jpadams/daggerverse/trivy@v0.5.0 call scan-image --help