Skip to main content

Types

In addition to basic types (string, boolean, integer, arrays...), the Dagger API also provides powerful core types which serve as both arguments and return values for Dagger Functions.

note

The types listed on this page are indicative and not exhaustive. For a complete list of supported types and their fields, refer to the Dagger API reference.

Core types

The following table lists available types and what they represent:

TypeDescription
CacheVolumeA directory whose contents persist across runs
ContainerAn OCI-compatible container
CurrentModuleThe current Dagger module and its context
EngineThe Dagger Engine configuration and state
DirectoryA directory (local path or Git reference)
EnvVariableAn environment variable name and value
EnvAn environment variable name and value
FileA file
GitRepositoryA Git repository
GitRefA Git reference (tag, branch, or commit)
HostThe Dagger host environment
LLMA Large Language Model (LLM)
ModuleA Dagger module
PortA port exposed by a container
SecretA secret credential like a password, access token or key)
ServiceA content-addressed service providing TCP connectivity
SocketA Unix or TCP/IP socket that can be mounted into a container
TerminalAn interactive terminal session

Each type exposes additional fields. Some of these are discussed on their respective pages.

Dagger modules

When you work with a Dagger workflow, you are using types that are comprised of one or more Dagger modules. A Dagger module is a collection of reusable code that can be shared and used across different workflows. Modules allow you to encapsulate functionality, making it easier to manage and maintain your code.

tip

In addition to the default Dagger types, you can create and add your own custom types to Dagger. These custom types can be used in Dagger modules and can be composed with other types to create complex workflows.

Learn more about creating custom types and developing Dagger modules in Extending Dagger.

As part of developing a Dagger module, you group your code into Dagger Functions. A Dagger Function is a piece of code that can be executed by the Dagger Engine, and it can return a value or perform an action (e.g creating and returning a base container, or publishing a container to a registry).

The recommended, and most common way, to interact with the Dagger API is through Dagger Functions. Dagger Functions are just regular code, written in your usual language using a type-safe Dagger SDK.

Dagger Functions are packaged, shared and reused using Dagger modules. A new Dagger module is initialized by calling dagger init. This creates a new dagger.json configuration file in the current working directory, together with sample Dagger Function source code. The configuration file will default the name of the module to the current directory name, unless an alternative is specified with the --name argument.

Once a module is initialized, dagger develop --sdk=... sets up or updates all the resources needed to develop the module locally using a Dagger SDK. By default, the module source code will be stored in the current working directory, unless an alternative is specified with the --source argument.

Here is an example of initializing a Dagger module:

dagger init --name=my-module
dagger develop --sdk=go
warning

Running dagger develop regenerates the module's code based on dependencies, the current state of the module, and the current Dagger API version. This can result in unexpected results if there are significant changes between the previous and latest installed Dagger API versions. Always refer to the changelog for a complete list of changes (including breaking changes) in each Dagger release before running dagger develop, or use the --compat=skip option to bypass updating the Dagger API version.