Client

Automatically generated client from Dagger API.

class dagger.Binding(ctx: Context)

Bases: Type

as_cache_volume() CacheVolume[source]

Retrieve the binding value, as type CacheVolume

as_container() Container[source]

Retrieve the binding value, as type Container

as_directory() Directory[source]

Retrieve the binding value, as type Directory

as_env() Env[source]

Retrieve the binding value, as type Env

as_file() File[source]

Retrieve the binding value, as type File

as_git_ref() GitRef[source]

Retrieve the binding value, as type GitRef

as_git_repository() GitRepository[source]

Retrieve the binding value, as type GitRepository

as_llm() LLM[source]

Retrieve the binding value, as type LLM

as_module() Module[source]

Retrieve the binding value, as type Module

as_module_config_client() ModuleConfigClient[source]

Retrieve the binding value, as type ModuleConfigClient

as_module_source() ModuleSource[source]

Retrieve the binding value, as type ModuleSource

as_secret() Secret[source]

Retrieve the binding value, as type Secret

as_service() Service[source]

Retrieve the binding value, as type Service

as_socket() Socket[source]

Retrieve the binding value, as type Socket

async as_string() str | None[source]

The binding’s string value

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str | None

Raises:
async digest() str[source]

The digest of the binding value

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() BindingID[source]

A unique identifier for this Binding.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The BindingID scalar type represents an identifier for an object of type Binding.

Return type:

BindingID

Raises:
async is_null() bool[source]

Returns true if the binding is null

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

Raises:
async name() str[source]

The binding name

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async type_name() str[source]

The binding type

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.BindingID

Bases: Scalar

The BindingID scalar type represents an identifier for an object of type Binding.

class dagger.BuildArg(name: str, value: str)

Bases: Input

Key value object that represents a build argument.

name: str
value: str
class dagger.CacheSharingMode(*values)

Bases: Enum

Sharing mode of the cache volume.

LOCKED = 'LOCKED'
PRIVATE = 'PRIVATE'
SHARED = 'SHARED'
class dagger.CacheVolume(ctx: Context)

Bases: Type

A directory whose contents persist across runs.

async id() CacheVolumeID[source]

A unique identifier for this CacheVolume.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The CacheVolumeID scalar type represents an identifier for an object of type CacheVolume.

Return type:

CacheVolumeID

Raises:
class dagger.CacheVolumeID

Bases: Scalar

The CacheVolumeID scalar type represents an identifier for an object of type CacheVolume.

class dagger.Client(ctx: Context | None = None)

Bases: Root

The root of the DAG.

cache_volume(key: str, *, namespace: str | None = '') CacheVolume[source]

Constructs a cache volume for a given cache key.

Parameters:
  • key – A string identifier to target this cache volume (e.g., “modules- cache”).

  • namespace

container(*, platform: Platform | None = None) Container[source]

Creates a scratch container, with no image or metadata.

To pull an image, follow up with the “from” function.

Parameters:

platform – Platform to initialize the container with. Defaults to the native platform of the current engine

current_function_call() FunctionCall[source]

The FunctionCall context that the SDK caller is currently executing in.

If the caller is not currently executing in a function, this will return an error.

current_module() CurrentModule[source]

The module currently being served in the session, if any.

async current_type_defs() list[TypeDef][source]

The TypeDef representations of the objects currently being served in the session.

async default_platform() Platform[source]

The default platform of the engine.

Returns:

The platform config OS and architecture in a Container. The format is [os]/[platform]/[version] (e.g., “darwin/arm64/v7”, “windows/amd64”, “linux/arm64”).

Return type:

Platform

Raises:
directory() Directory[source]

Creates an empty directory.

engine() Engine[source]

The Dagger engine container configuration and state

env(*, privileged: bool | None = False, writable: bool | None = False) Env[source]

Initialize a new environment

Caution

Experimental: Environments are not yet stabilized

Parameters:
  • privileged – Give the environment the same privileges as the caller: core API including host access, current module, and dependencies

  • writable – Allow new outputs to be declared and saved in the environment

error(message: str) Error[source]

Create a new error.

Parameters:

message – A brief description of the error.

file(name: str, contents: str, *, permissions: int | None = 420) File[source]

Creates a file with the specified contents.

Parameters:
  • name – Name of the new file. Example: “foo.txt”

  • contents – Contents of the new file. Example: “Hello world!”

  • permissions – Permissions of the new file. Example: 0600

function(name: str, return_type: TypeDef) Function[source]

Creates a function.

Parameters:
  • name – Name of the function, in its original format from the implementation language.

  • return_type – Return type of the function.

generated_code(code: Directory) GeneratedCode[source]

Create a code generation result, given a directory containing the generated code.

git(url: str, *, keep_git_dir: bool | None = True, ssh_known_hosts: str | None = '', ssh_auth_socket: Socket | None = None, http_auth_token: Secret | None = None, http_auth_header: Secret | None = None, experimental_service_host: Service | None = None) GitRepository[source]

Queries a Git repository.

Parameters:
  • url – URL of the git repository. Can be formatted as https://{host}/{owner}/{repo}, git@{host}:{owner}/{repo}. Suffix “.git” is optional.

  • keep_git_dir – DEPRECATED: Set to true to keep .git directory.

  • ssh_known_hosts – Set SSH known hosts

  • ssh_auth_socket – Set SSH auth socket

  • http_auth_token – Secret used to populate the password during basic HTTP Authorization

  • http_auth_header – Secret used to populate the Authorization HTTP header

  • experimental_service_host – A service which must be started before the repo is fetched.

host() Host[source]

Queries the host environment.

http(url: str, *, name: str | None = None, permissions: int | None = None, auth_header: Secret | None = None, experimental_service_host: Service | None = None) File[source]

Returns a file containing an http remote url content.

Parameters:
  • url – HTTP url to get the content from (e.g., “https://docs.dagger.io”).

  • name – File name to use for the file. Defaults to the last part of the URL.

  • permissions – Permissions to set on the file.

  • auth_header – Secret used to populate the Authorization HTTP header

  • experimental_service_host – A service which must be started before the URL is fetched.

llm(*, model: str | None = None, max_api_calls: int | None = None) LLM[source]

Initialize a Large Language Model (LLM)

Caution

Experimental: LLM support is not yet stabilized

Parameters:
  • model – Model to use

  • max_api_calls – Cap the number of API calls for this LLM

load_binding_from_id(id: BindingID) Binding[source]

Load a Binding from its ID.

load_cache_volume_from_id(id: CacheVolumeID) CacheVolume[source]

Load a CacheVolume from its ID.

load_container_from_id(id: ContainerID) Container[source]

Load a Container from its ID.

load_current_module_from_id(id: CurrentModuleID) CurrentModule[source]

Load a CurrentModule from its ID.

load_directory_from_id(id: DirectoryID) Directory[source]

Load a Directory from its ID.

load_engine_cache_entry_from_id(id: EngineCacheEntryID) EngineCacheEntry[source]

Load a EngineCacheEntry from its ID.

load_engine_cache_entry_set_from_id(id: EngineCacheEntrySetID) EngineCacheEntrySet[source]

Load a EngineCacheEntrySet from its ID.

load_engine_cache_from_id(id: EngineCacheID) EngineCache[source]

Load a EngineCache from its ID.

load_engine_from_id(id: EngineID) Engine[source]

Load a Engine from its ID.

load_enum_type_def_from_id(id: EnumTypeDefID) EnumTypeDef[source]

Load a EnumTypeDef from its ID.

load_enum_value_type_def_from_id(id: EnumValueTypeDefID) EnumValueTypeDef[source]

Load a EnumValueTypeDef from its ID.

load_env_from_id(id: EnvID) Env[source]

Load a Env from its ID.

load_env_variable_from_id(id: EnvVariableID) EnvVariable[source]

Load a EnvVariable from its ID.

load_error_from_id(id: ErrorID) Error[source]

Load a Error from its ID.

load_error_value_from_id(id: ErrorValueID) ErrorValue[source]

Load a ErrorValue from its ID.

load_field_type_def_from_id(id: FieldTypeDefID) FieldTypeDef[source]

Load a FieldTypeDef from its ID.

load_file_from_id(id: FileID) File[source]

Load a File from its ID.

load_function_arg_from_id(id: FunctionArgID) FunctionArg[source]

Load a FunctionArg from its ID.

load_function_call_arg_value_from_id(id: FunctionCallArgValueID) FunctionCallArgValue[source]

Load a FunctionCallArgValue from its ID.

load_function_call_from_id(id: FunctionCallID) FunctionCall[source]

Load a FunctionCall from its ID.

load_function_from_id(id: FunctionID) Function[source]

Load a Function from its ID.

load_generated_code_from_id(id: GeneratedCodeID) GeneratedCode[source]

Load a GeneratedCode from its ID.

load_git_ref_from_id(id: GitRefID) GitRef[source]

Load a GitRef from its ID.

load_git_repository_from_id(id: GitRepositoryID) GitRepository[source]

Load a GitRepository from its ID.

load_host_from_id(id: HostID) Host[source]

Load a Host from its ID.

load_input_type_def_from_id(id: InputTypeDefID) InputTypeDef[source]

Load a InputTypeDef from its ID.

load_interface_type_def_from_id(id: InterfaceTypeDefID) InterfaceTypeDef[source]

Load a InterfaceTypeDef from its ID.

load_label_from_id(id: LabelID) Label[source]

Load a Label from its ID.

load_list_type_def_from_id(id: ListTypeDefID) ListTypeDef[source]

Load a ListTypeDef from its ID.

load_llm_from_id(id: LLMID) LLM[source]

Load a LLM from its ID.

load_llm_token_usage_from_id(id: LLMTokenUsageID) LLMTokenUsage[source]

Load a LLMTokenUsage from its ID.

load_module_config_client_from_id(id: ModuleConfigClientID) ModuleConfigClient[source]

Load a ModuleConfigClient from its ID.

load_module_from_id(id: ModuleID) Module[source]

Load a Module from its ID.

load_module_source_from_id(id: ModuleSourceID) ModuleSource[source]

Load a ModuleSource from its ID.

load_object_type_def_from_id(id: ObjectTypeDefID) ObjectTypeDef[source]

Load a ObjectTypeDef from its ID.

load_port_from_id(id: PortID) Port[source]

Load a Port from its ID.

load_scalar_type_def_from_id(id: ScalarTypeDefID) ScalarTypeDef[source]

Load a ScalarTypeDef from its ID.

load_sdk_config_from_id(id: SDKConfigID) SDKConfig[source]

Load a SDKConfig from its ID.

load_secret_from_id(id: SecretID) Secret[source]

Load a Secret from its ID.

load_service_from_id(id: ServiceID) Service[source]

Load a Service from its ID.

load_socket_from_id(id: SocketID) Socket[source]

Load a Socket from its ID.

load_source_map_from_id(id: SourceMapID) SourceMap[source]

Load a SourceMap from its ID.

load_terminal_from_id(id: TerminalID) Terminal[source]

Load a Terminal from its ID.

load_type_def_from_id(id: TypeDefID) TypeDef[source]

Load a TypeDef from its ID.

module() Module[source]

Create a new module.

module_source(ref_string: str, *, ref_pin: str | None = '', disable_find_up: bool | None = False, allow_not_exists: bool | None = False, require_kind: ModuleSourceKind | None = None) ModuleSource[source]

Create a new module source instance from a source ref string

Parameters:
  • ref_string – The string ref representation of the module source

  • ref_pin – The pinned version of the module source

  • disable_find_up – If true, do not attempt to find dagger.json in a parent directory of the provided path. Only relevant for local module sources.

  • allow_not_exists – If true, do not error out if the provided ref string is a local path and does not exist yet. Useful when initializing new modules in directories that don’t exist yet.

  • require_kind – If set, error out if the ref string is not of the provided requireKind.

secret(uri: str, *, cache_key: str | None = None) Secret[source]

Creates a new secret.

Parameters:
  • uri – The URI of the secret store

  • cache_key – If set, the given string will be used as the cache key for this secret. This means that any secrets with the same cache key will be considered equivalent in terms of cache lookups, even if they have different URIs or plaintext values. For example, two secrets with the same cache key provided as secret env vars to other wise equivalent containers will result in the container withExecs hitting the cache for each other. If not set, the cache key for the secret will be derived from its plaintext value as looked up when the secret is constructed.

set_secret(name: str, plaintext: str) Secret[source]

Sets a secret given a user defined name to its plaintext and returns the secret.

The plaintext value is limited to a size of 128000 bytes.

Parameters:
  • name – The user defined name for this secret

  • plaintext – The plaintext of the secret

source_map(filename: str, line: int, column: int) SourceMap[source]

Creates source map metadata.

Parameters:
  • filename – The filename from the module source.

  • line – The line number within the filename.

  • column – The column number within the line.

type_def() TypeDef[source]

Create a new TypeDef.

async version() str[source]

Get the current Dagger Engine version.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.Container(ctx: Context)

Bases: Type

An OCI-compatible container, also known as a Docker container.

as_service(*, args: list[str] | None = None, use_entrypoint: bool | None = False, experimental_privileged_nesting: bool | None = False, insecure_root_capabilities: bool | None = False, expand: bool | None = False, no_init: bool | None = False) Service[source]

Turn the container into a Service.

Be sure to set any exposed ports before this conversion.

Parameters:
  • args – Command to run instead of the container’s default command (e.g., [“go”, “run”, “main.go”]). If empty, the container’s default command is used.

  • use_entrypoint – If the container has an entrypoint, prepend it to the args.

  • experimental_privileged_nesting – Provides Dagger access to the executed command.

  • insecure_root_capabilities – Execute the command with all root capabilities. This is similar to running a command with “sudo” or executing “docker run” with the ” –privileged” flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.

  • expand – Replace “${VAR}” or “$VAR” in the args according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

  • no_init – If set, skip the automatic init process injected into containers by default. This should only be used if the user requires that their exec process be the pid 1 process in the container. Otherwise it may result in unexpected behavior.

as_tarball(*, platform_variants: list[Container] | None = None, forced_compression: ImageLayerCompression | None = None, media_types: ImageMediaTypes | None = ImageMediaTypes.OCIMediaTypes) File[source]

Package the container state as an OCI image, and return it as a tar archive

Parameters:
  • platform_variants – Identifiers for other platform specific containers. Used for multi-platform images.

  • forced_compression – Force each layer of the image to use the specified compression algorithm. If this is unset, then if a layer already has a compressed blob in the engine’s cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine’s cache, then it will be compressed using Gzip.

  • media_types – Use the specified media types for the image’s layers. Defaults to OCI, which is largely compatible with most recent container runtimes, but Docker may be needed for older runtimes without OCI support.

build(context: Directory, *, dockerfile: str | None = 'Dockerfile', target: str | None = '', build_args: list[BuildArg] | None = None, secrets: list[Secret] | None = None, no_init: bool | None = False) Self[source]

Initializes this container from a Dockerfile build.

Parameters:
  • context – Directory context used by the Dockerfile.

  • dockerfile – Path to the Dockerfile to use.

  • target – Target build stage to build.

  • build_args – Additional build arguments.

  • secrets – Secrets to pass to the build. They will be mounted at /run/secrets/[secret-name] in the build container They can be accessed in the Dockerfile using the “secret” mount type and mount path /run/secrets/[secret-name], e.g. RUN –mount=type=secret,id=my-secret curl [http://example.com?token=$(cat /run/secrets/my- secret)](http://example.com?token=$(cat /run/secrets/my-secret))

  • no_init – If set, skip the automatic init process injected into containers created by RUN statements. This should only be used if the user requires that their exec processes be the pid 1 process in the container. Otherwise it may result in unexpected behavior.

async default_args() list[str][source]

Return the container’s default arguments.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
directory(path: str, *, expand: bool | None = False) Directory[source]

Retrieve a directory from the container’s root filesystem

Mounts are included.

Parameters:
  • path – The path of the directory to retrieve (e.g., “./src”).

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

async entrypoint() list[str][source]

Return the container’s OCI entrypoint.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
async env_variable(name: str) str | None[source]

Retrieves the value of the specified environment variable.

Parameters:

name – The name of the environment variable to retrieve (e.g., “PATH”).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str | None

Raises:
async env_variables() list[EnvVariable][source]

Retrieves the list of environment variables passed to commands.

async exit_code() int[source]

The exit code of the last executed command

Returns an error if no command was executed

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
experimental_with_all_gp_us() Self[source]

EXPERIMENTAL API! Subject to change/removal at any time.

Configures all available GPUs on the host to be accessible to this container.

This currently works for Nvidia devices only.

experimental_with_gpu(devices: list[str]) Self[source]

EXPERIMENTAL API! Subject to change/removal at any time.

Configures the provided list of devices to be accessible to this container.

This currently works for Nvidia devices only.

Parameters:

devices – List of devices to be accessible to this container.

async export(path: str, *, platform_variants: list[Container] | None = None, forced_compression: ImageLayerCompression | None = None, media_types: ImageMediaTypes | None = ImageMediaTypes.OCIMediaTypes, expand: bool | None = False) str[source]

Writes the container as an OCI tarball to the destination file path on the host.

It can also export platform variants.

Parameters:
  • path – Host’s destination path (e.g., “./tarball”). Path can be relative to the engine’s workdir or absolute.

  • platform_variants – Identifiers for other platform specific containers. Used for multi-platform image.

  • forced_compression – Force each layer of the exported image to use the specified compression algorithm. If this is unset, then if a layer already has a compressed blob in the engine’s cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine’s cache, then it will be compressed using Gzip.

  • media_types – Use the specified media types for the exported image’s layers. Defaults to OCI, which is largely compatible with most recent container runtimes, but Docker may be needed for older runtimes without OCI support.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async exposed_ports() list[Port][source]

Retrieves the list of exposed ports.

This includes ports already exposed by the image, even if not explicitly added with dagger.

file(path: str, *, expand: bool | None = False) File[source]

Retrieves a file at the given path.

Mounts are included.

Parameters:
  • path – The path of the file to retrieve (e.g., “./README.md”).

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo.txt”).

from_(address: str) Self[source]

Download a container image, and apply it to the container state. All previous state will be lost.

Parameters:

address – Address of the container image to download, in standard OCI ref format. Example:”registry.dagger.io/engine:latest”

async id() ContainerID[source]

A unique identifier for this Container.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The ContainerID scalar type represents an identifier for an object of type Container.

Return type:

ContainerID

Raises:
async image_ref() str[source]

The unique image reference which can only be retrieved immediately after the ‘Container.From’ call.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
import_(source: File, *, tag: str | None = '') Self[source]

Reads the container from an OCI tarball.

Parameters:
  • source – File to read the container from.

  • tag – Identifies the tag to import from the archive, if the archive bundles multiple tags.

async label(name: str) str | None[source]

Retrieves the value of the specified label.

Parameters:

name – The name of the label (e.g., “org.opencontainers.artifact.created”).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str | None

Raises:
async labels() list[Label][source]

Retrieves the list of labels passed to container.

async mounts() list[str][source]

Retrieves the list of paths where a directory is mounted.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
async platform() Platform[source]

The platform this container executes and publishes as.

Returns:

The platform config OS and architecture in a Container. The format is [os]/[platform]/[version] (e.g., “darwin/arm64/v7”, “windows/amd64”, “linux/arm64”).

Return type:

Platform

Raises:
async publish(address: str, *, platform_variants: list[Container] | None = None, forced_compression: ImageLayerCompression | None = None, media_types: ImageMediaTypes | None = ImageMediaTypes.OCIMediaTypes) str[source]

Package the container state as an OCI image, and publish it to a registry

Returns the fully qualified address of the published image, with digest

Parameters:
  • address – The OCI address to publish to Same format as “docker push”. Example: “registry.example.com/user/repo:tag”

  • platform_variants – Identifiers for other platform specific containers. Used for multi-platform image.

  • forced_compression – Force each layer of the published image to use the specified compression algorithm. If this is unset, then if a layer already has a compressed blob in the engine’s cache, that will be used (this can result in a mix of compression algorithms for different layers). If this is unset and a layer has no compressed blob in the engine’s cache, then it will be compressed using Gzip.

  • media_types – Use the specified media types for the published image’s layers. Defaults to “OCI”, which is compatible with most recent registries, but “Docker” may be needed for older registries without OCI support.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
rootfs() Directory[source]

Return a snapshot of the container’s root filesystem. The snapshot can be modified then written back using withRootfs. Use that method for filesystem modifications.

async stderr() str[source]

The buffered standard error stream of the last executed command

Returns an error if no command was executed

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async stdout() str[source]

The buffered standard output stream of the last executed command

Returns an error if no command was executed

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async sync() Self[source]

Forces evaluation of the pipeline in the engine.

It doesn’t run the default command if no exec has been set.

Raises:
terminal(*, cmd: list[str] | None = None, experimental_privileged_nesting: bool | None = False, insecure_root_capabilities: bool | None = False) Self[source]

Opens an interactive terminal for this container using its configured default terminal command if not overridden by args (or sh as a fallback default).

Parameters:
  • cmd – If set, override the container’s default terminal command and invoke these command arguments instead.

  • experimental_privileged_nesting – Provides Dagger access to the executed command.

  • insecure_root_capabilities – Execute the command with all root capabilities. This is similar to running a command with “sudo” or executing “docker run” with the ” –privileged” flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.

async up(*, random: bool | None = False, ports: list[PortForward] | None = None, args: list[str] | None = None, use_entrypoint: bool | None = False, experimental_privileged_nesting: bool | None = False, insecure_root_capabilities: bool | None = False, expand: bool | None = False, no_init: bool | None = False) Void | None[source]

Starts a Service and creates a tunnel that forwards traffic from the caller’s network to that service.

Be sure to set any exposed ports before calling this api.

Parameters:
  • random – Bind each tunnel port to a random port on the host.

  • ports – List of frontend/backend port mappings to forward. Frontend is the port accepting traffic on the host, backend is the service port.

  • args – Command to run instead of the container’s default command (e.g., [“go”, “run”, “main.go”]). If empty, the container’s default command is used.

  • use_entrypoint – If the container has an entrypoint, prepend it to the args.

  • experimental_privileged_nesting – Provides Dagger access to the executed command.

  • insecure_root_capabilities – Execute the command with all root capabilities. This is similar to running a command with “sudo” or executing “docker run” with the ” –privileged” flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.

  • expand – Replace “${VAR}” or “$VAR” in the args according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

  • no_init – If set, skip the automatic init process injected into containers by default. This should only be used if the user requires that their exec process be the pid 1 process in the container. Otherwise it may result in unexpected behavior.

Returns:

The absence of a value. A Null Void is used as a placeholder for resolvers that do not return anything.

Return type:

Void | None

Raises:
async user() str[source]

Retrieves the user to be set for all commands.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
with_(cb: Callable[[Container], Container]) Container[source]

Call the provided callable with current Container.

This is useful for reusability and readability by not breaking the calling chain.

with_annotation(name: str, value: str) Self[source]

Retrieves this container plus the given OCI anotation.

Parameters:
  • name – The name of the annotation.

  • value – The value of the annotation.

with_default_args(args: list[str]) Self[source]

Configures default arguments for future commands. Like CMD in Dockerfile.

Parameters:

args – Arguments to prepend to future executions (e.g., [“-v”, “–no- cache”]).

with_default_terminal_cmd(args: list[str], *, experimental_privileged_nesting: bool | None = False, insecure_root_capabilities: bool | None = False) Self[source]

Set the default command to invoke for the container’s terminal API.

Parameters:
  • args – The args of the command.

  • experimental_privileged_nesting – Provides Dagger access to the executed command.

  • insecure_root_capabilities – Execute the command with all root capabilities. This is similar to running a command with “sudo” or executing “docker run” with the ” –privileged” flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.

with_directory(path: str, directory: Directory, *, exclude: list[str] | None = None, include: list[str] | None = None, owner: str | None = '', expand: bool | None = False) Self[source]

Return a new container snapshot, with a directory added to its filesystem

Parameters:
  • path – Location of the written directory (e.g., “/tmp/directory”).

  • directory – Identifier of the directory to write

  • exclude – Patterns to exclude in the written directory (e.g. [“node_modules/**”, “.gitignore”, “.git/”]).

  • include – Patterns to include in the written directory (e.g. [”*.go”, “go.mod”, “go.sum”]).

  • owner – A user:group to set for the directory and its contents. The user and group can either be an ID (1000:1000) or a name (foo:bar). If the group is omitted, it defaults to the same as the user.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

with_entrypoint(args: list[str], *, keep_default_args: bool | None = False) Self[source]

Set an OCI-style entrypoint. It will be included in the container’s OCI configuration. Note, withExec ignores the entrypoint by default.

Parameters:
  • args – Arguments of the entrypoint. Example: [“go”, “run”].

  • keep_default_args – Don’t reset the default arguments when setting the entrypoint. By default it is reset, since entrypoint and default args are often tightly coupled.

with_env_variable(name: str, value: str, *, expand: bool | None = False) Self[source]

Set a new environment variable in the container.

Parameters:
  • name – Name of the environment variable (e.g., “HOST”).

  • value – Value of the environment variable. (e.g., “localhost”).

  • expand – Replace “${VAR}” or “$VAR” in the value according to the current environment variables defined in the container (e.g. “/opt/bin:$PATH”).

with_exec(args: list[str], *, use_entrypoint: bool | None = False, stdin: str | None = '', redirect_stdout: str | None = '', redirect_stderr: str | None = '', expect: ReturnType | None = ReturnType.SUCCESS, experimental_privileged_nesting: bool | None = False, insecure_root_capabilities: bool | None = False, expand: bool | None = False, no_init: bool | None = False) Self[source]

Execute a command in the container, and return a new snapshot of the container state after execution.

Parameters:
  • args – Command to execute. Must be valid exec() arguments, not a shell command. Example: [“go”, “run”, “main.go”]. To run a shell command, execute the shell and pass the shell command as argument. Example: [“sh”, “-c”, “ls -l | grep foo”] Defaults to the container’s default arguments (see “defaultArgs” and “withDefaultArgs”).

  • use_entrypoint – Apply the OCI entrypoint, if present, by prepending it to the args. Ignored by default.

  • stdin – Content to write to the command’s standard input. Example: “Hello world”)

  • redirect_stdout – Redirect the command’s standard output to a file in the container. Example: “./stdout.txt”

  • redirect_stderr – Like redirectStdout, but for standard error

  • expect – Exit codes this command is allowed to exit with without error

  • experimental_privileged_nesting – Provides Dagger access to the executed command.

  • insecure_root_capabilities – Execute the command with all root capabilities. Like –privileged in Docker DANGER: this grants the command full access to the host system. Only use when 1) you trust the command being executed and 2) you specifically need this level of access.

  • expand – Replace “${VAR}” or “$VAR” in the args according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

  • no_init – Skip the automatic init process injected into containers by default. Only use this if you specifically need the command to be pid 1 in the container. Otherwise it may result in unexpected behavior. If you’re not sure, you don’t need this.

with_exposed_port(port: int, *, protocol: NetworkProtocol | None = NetworkProtocol.TCP, description: str | None = None, experimental_skip_healthcheck: bool | None = False) Self[source]

Expose a network port. Like EXPOSE in Dockerfile (but with healthcheck support)

Exposed ports serve two purposes:

  • For health checks and introspection, when running services

  • For setting the EXPOSE OCI field when publishing the container

Parameters:
  • port – Port number to expose. Example: 8080

  • protocol – Network protocol. Example: “tcp”

  • description – Port description. Example: “payment API endpoint”

  • experimental_skip_healthcheck – Skip the health check when run as a service.

with_file(path: str, source: File, *, permissions: int | None = None, owner: str | None = '', expand: bool | None = False) Self[source]

Return a container snapshot with a file added

Parameters:
  • path – Path of the new file. Example: “/path/to/new-file.txt”

  • source – File to add

  • permissions – Permissions of the new file. Example: 0600

  • owner – A user:group to set for the file. The user and group can either be an ID (1000:1000) or a name (foo:bar). If the group is omitted, it defaults to the same as the user.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo.txt”).

with_files(path: str, sources: list[File], *, permissions: int | None = None, owner: str | None = '', expand: bool | None = False) Self[source]

Retrieves this container plus the contents of the given files copied to the given path.

Parameters:
  • path – Location where copied files should be placed (e.g., “/src”).

  • sources – Identifiers of the files to copy.

  • permissions – Permission given to the copied files (e.g., 0600).

  • owner – A user:group to set for the files. The user and group can either be an ID (1000:1000) or a name (foo:bar). If the group is omitted, it defaults to the same as the user.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo.txt”).

with_label(name: str, value: str) Self[source]

Retrieves this container plus the given label.

Parameters:
  • name – The name of the label (e.g., “org.opencontainers.artifact.created”).

  • value – The value of the label (e.g., “2023-01-01T00:00:00Z”).

with_mounted_cache(path: str, cache: CacheVolume, *, source: Directory | None = None, sharing: CacheSharingMode | None = CacheSharingMode.SHARED, owner: str | None = '', expand: bool | None = False) Self[source]

Retrieves this container plus a cache volume mounted at the given path.

Parameters:
  • path – Location of the cache directory (e.g., “/root/.npm”).

  • cache – Identifier of the cache volume to mount.

  • source – Identifier of the directory to use as the cache volume’s root.

  • sharing – Sharing mode of the cache volume.

  • owner – A user:group to set for the mounted cache directory. Note that this changes the ownership of the specified mount along with the initial filesystem provided by source (if any). It does not have any effect if/when the cache has already been created. The user and group can either be an ID (1000:1000) or a name (foo:bar). If the group is omitted, it defaults to the same as the user.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

with_mounted_directory(path: str, source: Directory, *, owner: str | None = '', expand: bool | None = False) Self[source]

Retrieves this container plus a directory mounted at the given path.

Parameters:
  • path – Location of the mounted directory (e.g., “/mnt/directory”).

  • source – Identifier of the mounted directory.

  • owner – A user:group to set for the mounted directory and its contents. The user and group can either be an ID (1000:1000) or a name (foo:bar). If the group is omitted, it defaults to the same as the user.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

with_mounted_file(path: str, source: File, *, owner: str | None = '', expand: bool | None = False) Self[source]

Retrieves this container plus a file mounted at the given path.

Parameters:
  • path – Location of the mounted file (e.g., “/tmp/file.txt”).

  • source – Identifier of the mounted file.

  • owner – A user or user:group to set for the mounted file. The user and group can either be an ID (1000:1000) or a name (foo:bar). If the group is omitted, it defaults to the same as the user.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo.txt”).

with_mounted_secret(path: str, source: Secret, *, owner: str | None = '', mode: int | None = 256, expand: bool | None = False) Self[source]

Retrieves this container plus a secret mounted into a file at the given path.

Parameters:
  • path – Location of the secret file (e.g., “/tmp/secret.txt”).

  • source – Identifier of the secret to mount.

  • owner – A user:group to set for the mounted secret. The user and group can either be an ID (1000:1000) or a name (foo:bar). If the group is omitted, it defaults to the same as the user.

  • mode – Permission given to the mounted secret (e.g., 0600). This option requires an owner to be set to be active.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

with_mounted_temp(path: str, *, size: int | None = None, expand: bool | None = False) Self[source]

Retrieves this container plus a temporary directory mounted at the given path. Any writes will be ephemeral to a single withExec call; they will not be persisted to subsequent withExecs.

Parameters:
  • path – Location of the temporary directory (e.g., “/tmp/temp_dir”).

  • size – Size of the temporary directory in bytes.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

with_new_file(path: str, contents: str, *, permissions: int | None = 420, owner: str | None = '', expand: bool | None = False) Self[source]

Return a new container snapshot, with a file added to its filesystem with text content

Parameters:
  • path – Path of the new file. May be relative or absolute. Example: “README.md” or “/etc/profile”

  • contents – Contents of the new file. Example: “Hello world!”

  • permissions – Permissions of the new file. Example: 0600

  • owner – A user:group to set for the file. The user and group can either be an ID (1000:1000) or a name (foo:bar). If the group is omitted, it defaults to the same as the user.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo.txt”).

with_registry_auth(address: str, username: str, secret: Secret) Self[source]

Attach credentials for future publishing to a registry. Use in combination with publish

Parameters:
  • address – The image address that needs authentication. Same format as “docker push”. Example: “registry.dagger.io/dagger:latest”

  • username – The username to authenticate with. Example: “alice”

  • secret – The API key, password or token to authenticate to this registry

with_rootfs(directory: Directory) Self[source]

Change the container’s root filesystem. The previous root filesystem will be lost.

Parameters:

directory – The new root filesystem.

with_secret_variable(name: str, secret: Secret) Self[source]

Set a new environment variable, using a secret value

Parameters:
  • name – Name of the secret variable (e.g., “API_SECRET”).

  • secret – Identifier of the secret value.

with_service_binding(alias: str, service: Service) Self[source]

Establish a runtime dependency from a container to a network service.

The service will be started automatically when needed and detached when it is no longer needed, executing the default command if none is set.

The service will be reachable from the container via the provided hostname alias.

The service dependency will also convey to any files or directories produced by the container.

Parameters:
  • alias – Hostname that will resolve to the target service (only accessible from within this container)

  • service – The target service

Return a snapshot with a symlink

Parameters:
  • target – Location of the file or directory to link to (e.g., “/existing/file”).

  • link_name – Location where the symbolic link will be created (e.g., “/new- file-link”).

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo.txt”).

with_unix_socket(path: str, source: Socket, *, owner: str | None = '', expand: bool | None = False) Self[source]

Retrieves this container plus a socket forwarded to the given Unix socket path.

Parameters:
  • path – Location of the forwarded Unix socket (e.g., “/tmp/socket”).

  • source – Identifier of the socket to forward.

  • owner – A user:group to set for the mounted socket. The user and group can either be an ID (1000:1000) or a name (foo:bar). If the group is omitted, it defaults to the same as the user.

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

with_user(name: str) Self[source]

Retrieves this container with a different command user.

Parameters:

name – The user to set (e.g., “root”).

with_workdir(path: str, *, expand: bool | None = False) Self[source]

Change the container’s working directory. Like WORKDIR in Dockerfile.

Parameters:
  • path – The path to set as the working directory (e.g., “/app”).

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

without_annotation(name: str) Self[source]

Retrieves this container minus the given OCI annotation.

Parameters:

name – The name of the annotation.

without_default_args() Self[source]

Remove the container’s default arguments.

without_directory(path: str, *, expand: bool | None = False) Self[source]

Return a new container snapshot, with a directory removed from its filesystem

Parameters:
  • path – Location of the directory to remove (e.g., “.github/”).

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

without_entrypoint(*, keep_default_args: bool | None = False) Self[source]

Reset the container’s OCI entrypoint.

Parameters:

keep_default_args – Don’t remove the default arguments when unsetting the entrypoint.

without_env_variable(name: str) Self[source]

Retrieves this container minus the given environment variable.

Parameters:

name – The name of the environment variable (e.g., “HOST”).

without_exposed_port(port: int, *, protocol: NetworkProtocol | None = NetworkProtocol.TCP) Self[source]

Unexpose a previously exposed port.

Parameters:
  • port – Port number to unexpose

  • protocol – Port protocol to unexpose

without_file(path: str, *, expand: bool | None = False) Self[source]

Retrieves this container with the file at the given path removed.

Parameters:
  • path – Location of the file to remove (e.g., “/file.txt”).

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo.txt”).

without_files(paths: list[str], *, expand: bool | None = False) Self[source]

Return a new container spanshot with specified files removed

Parameters:
  • paths – Paths of the files to remove. Example: [“foo.txt, “/root/.ssh/config”

  • expand – Replace “${VAR}” or “$VAR” in the value of paths according to the current environment variables defined in the container (e.g. “/$VAR/foo.txt”).

without_label(name: str) Self[source]

Retrieves this container minus the given environment label.

Parameters:

name – The name of the label to remove (e.g., “org.opencontainers.artifact.created”).

without_mount(path: str, *, expand: bool | None = False) Self[source]

Retrieves this container after unmounting everything at the given path.

Parameters:
  • path – Location of the cache directory (e.g., “/root/.npm”).

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

without_registry_auth(address: str) Self[source]

Retrieves this container without the registry authentication of a given address.

Parameters:

address – Registry’s address to remove the authentication from. Formatted as [host]/[user]/[repo]:[tag] (e.g. docker.io/dagger/dagger:main).

without_secret_variable(name: str) Self[source]

Retrieves this container minus the given environment variable containing the secret.

Parameters:

name – The name of the environment variable (e.g., “HOST”).

without_unix_socket(path: str, *, expand: bool | None = False) Self[source]

Retrieves this container with a previously added Unix socket removed.

Parameters:
  • path – Location of the socket to remove (e.g., “/tmp/socket”).

  • expand – Replace “${VAR}” or “$VAR” in the value of path according to the current environment variables defined in the container (e.g. “/$VAR/foo”).

without_user() Self[source]

Retrieves this container with an unset command user.

Should default to root.

without_workdir() Self[source]

Unset the container’s working directory.

Should default to “/”.

async workdir() str[source]

Retrieves the working directory for all commands.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.ContainerID

Bases: Scalar

The ContainerID scalar type represents an identifier for an object of type Container.

class dagger.CurrentModule(ctx: Context)

Bases: Type

Reflective module API provided to functions at runtime.

async id() CurrentModuleID[source]

A unique identifier for this CurrentModule.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The CurrentModuleID scalar type represents an identifier for an object of type CurrentModule.

Return type:

CurrentModuleID

Raises:
async name() str[source]

The name of the module being executed in

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
source() Directory[source]

The directory containing the module’s source code loaded into the engine (plus any generated code that may have been created).

workdir(path: str, *, exclude: list[str] | None = None, include: list[str] | None = None) Directory[source]

Load a directory from the module’s scratch working directory, including any changes that may have been made to it during module function execution.

Parameters:
  • path – Location of the directory to access (e.g., “.”).

  • exclude – Exclude artifacts that match the given pattern (e.g., [“node_modules/”, “.git*”]).

  • include – Include only artifacts that match the given pattern (e.g., [“app/”, “package.*”]).

workdir_file(path: str) File[source]

Load a file from the module’s scratch working directory, including any changes that may have been made to it during module function execution.Load a file from the module’s scratch working directory, including any changes that may have been made to it during module function execution.

Parameters:

path – Location of the file to retrieve (e.g., “README.md”).

class dagger.CurrentModuleID

Bases: Scalar

The CurrentModuleID scalar type represents an identifier for an object of type CurrentModule.

class dagger.Directory(ctx: Context)

Bases: Type

A directory.

as_git() GitRepository[source]

Converts this directory to a local git repository

as_module(*, source_root_path: str | None = '.') Module[source]

Load the directory as a Dagger module source

Parameters:

source_root_path – An optional subpath of the directory which contains the module’s configuration file. If not set, the module source code is loaded from the root of the directory.

as_module_source(*, source_root_path: str | None = '.') ModuleSource[source]

Load the directory as a Dagger module source

Parameters:

source_root_path – An optional subpath of the directory which contains the module’s configuration file. If not set, the module source code is loaded from the root of the directory.

diff(other: Self) Self[source]

Return the difference between this directory and an another directory. The difference is encoded as a directory.

Parameters:

other – The directory to compare against

async digest() str[source]

Return the directory’s digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
directory(path: str) Self[source]

Retrieves a directory at the given path.

Parameters:

path – Location of the directory to retrieve. Example: “/src”

docker_build(*, dockerfile: str | None = 'Dockerfile', platform: Platform | None = None, build_args: list[BuildArg] | None = None, target: str | None = '', secrets: list[Secret] | None = None, no_init: bool | None = False) Container[source]

Use Dockerfile compatibility to build a container from this directory. Only use this function for Dockerfile compatibility. Otherwise use the native Container type directly, it is feature-complete and supports all Dockerfile features.

Parameters:
  • dockerfile – Path to the Dockerfile to use (e.g., “frontend.Dockerfile”).

  • platform – The platform to build.

  • build_args – Build arguments to use in the build.

  • target – Target build stage to build.

  • secrets – Secrets to pass to the build. They will be mounted at /run/secrets/[secret-name].

  • no_init – If set, skip the automatic init process injected into containers created by RUN statements. This should only be used if the user requires that their exec processes be the pid 1 process in the container. Otherwise it may result in unexpected behavior.

async entries(*, path: str | None = None) list[str][source]

Returns a list of files and directories at the given path.

Parameters:

path – Location of the directory to look at (e.g., “/src”).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
async export(path: str, *, wipe: bool | None = False) str[source]

Writes the contents of the directory to a path on the host.

Parameters:
  • path – Location of the copied directory (e.g., “logs/”).

  • wipe – If true, then the host directory will be wiped clean before exporting so that it exactly matches the directory being exported; this means it will delete any files on the host that aren’t in the exported dir. If false (the default), the contents of the directory will be merged with any existing contents of the host directory, leaving any existing files on the host that aren’t in the exported directory alone.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
file(path: str) File[source]

Retrieve a file at the given path.

Parameters:

path – Location of the file to retrieve (e.g., “README.md”).

filter(*, exclude: list[str] | None = None, include: list[str] | None = None) Self[source]

Return a snapshot with some paths included or excluded

Parameters:
  • exclude – If set, paths matching one of these glob patterns is excluded from the new snapshot. Example: [“node_modules/”, “.git*”, “.env”]

  • include – If set, only paths matching one of these glob patterns is included in the new snapshot. Example: (e.g., [“app/”, “package.*”]).

async glob(pattern: str) list[str][source]

Returns a list of files and directories that matche the given pattern.

Parameters:

pattern – Pattern to match (e.g., “*.md”).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
async id() DirectoryID[source]

A unique identifier for this Directory.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The DirectoryID scalar type represents an identifier for an object of type Directory.

Return type:

DirectoryID

Raises:
async name() str[source]

Returns the name of the directory.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async sync() Self[source]

Force evaluation in the engine.

Raises:
terminal(*, container: Container | None = None, cmd: list[str] | None = None, experimental_privileged_nesting: bool | None = False, insecure_root_capabilities: bool | None = False) Self[source]

Opens an interactive terminal in new container with this directory mounted inside.

Parameters:
  • container – If set, override the default container used for the terminal.

  • cmd – If set, override the container’s default terminal command and invoke these command arguments instead.

  • experimental_privileged_nesting – Provides Dagger access to the executed command.

  • insecure_root_capabilities – Execute the command with all root capabilities. This is similar to running a command with “sudo” or executing “docker run” with the ” –privileged” flag. Containerization does not provide any security guarantees when using this option. It should only be used when absolutely necessary and only with trusted commands.

with_(cb: Callable[[Directory], Directory]) Directory[source]

Call the provided callable with current Directory.

This is useful for reusability and readability by not breaking the calling chain.

with_directory(path: str, directory: Self, *, exclude: list[str] | None = None, include: list[str] | None = None) Self[source]

Return a snapshot with a directory added

Parameters:
  • path – Location of the written directory (e.g., “/src/”).

  • directory – Identifier of the directory to copy.

  • exclude – Exclude artifacts that match the given pattern (e.g., [“node_modules/”, “.git*”]).

  • include – Include only artifacts that match the given pattern (e.g., [“app/”, “package.*”]).

with_file(path: str, source: File, *, permissions: int | None = None) Self[source]

Retrieves this directory plus the contents of the given file copied to the given path.

Parameters:
  • path – Location of the copied file (e.g., “/file.txt”).

  • source – Identifier of the file to copy.

  • permissions – Permission given to the copied file (e.g., 0600).

with_files(path: str, sources: list[File], *, permissions: int | None = None) Self[source]

Retrieves this directory plus the contents of the given files copied to the given path.

Parameters:
  • path – Location where copied files should be placed (e.g., “/src”).

  • sources – Identifiers of the files to copy.

  • permissions – Permission given to the copied files (e.g., 0600).

with_new_directory(path: str, *, permissions: int | None = 420) Self[source]

Retrieves this directory plus a new directory created at the given path.

Parameters:
  • path – Location of the directory created (e.g., “/logs”).

  • permissions – Permission granted to the created directory (e.g., 0777).

with_new_file(path: str, contents: str, *, permissions: int | None = 420) Self[source]

Return a snapshot with a new file added

Parameters:
  • path – Path of the new file. Example: “foo/bar.txt”

  • contents – Contents of the new file. Example: “Hello world!”

  • permissions – Permissions of the new file. Example: 0600

Return a snapshot with a symlink

Parameters:
  • target – Location of the file or directory to link to (e.g., “/existing/file”).

  • link_name – Location where the symbolic link will be created (e.g., “/new- file-link”).

with_timestamps(timestamp: int) Self[source]

Retrieves this directory with all file/dir timestamps set to the given time.

Parameters:

timestamp – Timestamp to set dir/files in. Formatted in seconds following Unix epoch (e.g., 1672531199).

without_directory(path: str) Self[source]

Return a snapshot with a subdirectory removed

Parameters:

path – Path of the subdirectory to remove. Example: “.github/workflows”

without_file(path: str) Self[source]

Return a snapshot with a file removed

Parameters:

path – Path of the file to remove (e.g., “/file.txt”).

without_files(paths: list[str]) Self[source]

Return a snapshot with files removed

Parameters:

paths – Paths of the files to remove (e.g., [“/file.txt”]).

class dagger.DirectoryID

Bases: Scalar

The DirectoryID scalar type represents an identifier for an object of type Directory.

class dagger.Engine(ctx: Context)

Bases: Type

The Dagger engine configuration and state

async id() EngineID[source]

A unique identifier for this Engine.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The EngineID scalar type represents an identifier for an object of type Engine.

Return type:

EngineID

Raises:
local_cache() EngineCache[source]

The local (on-disk) cache for the Dagger engine

class dagger.EngineCache(ctx: Context)

Bases: Type

A cache storage for the Dagger engine

entry_set(*, key: str | None = '') EngineCacheEntrySet[source]

The current set of entries in the cache

async id() EngineCacheID[source]

A unique identifier for this EngineCache.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The EngineCacheID scalar type represents an identifier for an object of type EngineCache.

Return type:

EngineCacheID

Raises:
async keep_bytes() int[source]

The maximum bytes to keep in the cache without pruning, after which automatic pruning may kick in.

Deprecated

Use minFreeSpace instead.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async max_used_space() int[source]

The maximum bytes to keep in the cache without pruning.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async min_free_space() int[source]

The target amount of free disk space the garbage collector will attempt to leave.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async prune(*, use_default_policy: bool | None = False) Void | None[source]

Prune the cache of releaseable entries

Parameters:

use_default_policy – Use the engine-wide default pruning policy if true, otherwise prune the whole cache of any releasable entries.

Returns:

The absence of a value. A Null Void is used as a placeholder for resolvers that do not return anything.

Return type:

Void | None

Raises:
async reserved_space() int[source]

The minimum amount of disk space this policy is guaranteed to retain.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async target_space() int[source]

The target number of bytes to keep when pruning.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
class dagger.EngineCacheEntry(ctx: Context)

Bases: Type

An individual cache entry in a cache entry set

async actively_used() bool[source]

Whether the cache entry is actively being used.

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

Raises:
async created_time_unix_nano() int[source]

The time the cache entry was created, in Unix nanoseconds.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async description() str[source]

The description of the cache entry.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async disk_space_bytes() int[source]

The disk space used by the cache entry.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async id() EngineCacheEntryID[source]

A unique identifier for this EngineCacheEntry.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The EngineCacheEntryID scalar type represents an identifier for an object of type EngineCacheEntry.

Return type:

EngineCacheEntryID

Raises:
async most_recent_use_time_unix_nano() int[source]

The most recent time the cache entry was used, in Unix nanoseconds.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
class dagger.EngineCacheEntryID

Bases: Scalar

The EngineCacheEntryID scalar type represents an identifier for an object of type EngineCacheEntry.

class dagger.EngineCacheEntrySet(ctx: Context)

Bases: Type

A set of cache entries returned by a query to a cache

async disk_space_bytes() int[source]

The total disk space used by the cache entries in this set.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async entries() list[EngineCacheEntry][source]

The list of individual cache entries in the set

async entry_count() int[source]

The number of cache entries in this set.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async id() EngineCacheEntrySetID[source]

A unique identifier for this EngineCacheEntrySet.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The EngineCacheEntrySetID scalar type represents an identifier for an object of type EngineCacheEntrySet.

Return type:

EngineCacheEntrySetID

Raises:
class dagger.EngineCacheEntrySetID

Bases: Scalar

The EngineCacheEntrySetID scalar type represents an identifier for an object of type EngineCacheEntrySet.

class dagger.EngineCacheID

Bases: Scalar

The EngineCacheID scalar type represents an identifier for an object of type EngineCache.

class dagger.EngineID

Bases: Scalar

The EngineID scalar type represents an identifier for an object of type Engine.

class dagger.EnumTypeDef(ctx: Context)

Bases: Type

A definition of a custom enum defined in a Module.

async description() str[source]

A doc string for the enum, if any.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() EnumTypeDefID[source]

A unique identifier for this EnumTypeDef.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The EnumTypeDefID scalar type represents an identifier for an object of type EnumTypeDef.

Return type:

EnumTypeDefID

Raises:
async name() str[source]

The name of the enum.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
source_map() SourceMap[source]

The location of this enum declaration.

async source_module_name() str[source]

If this EnumTypeDef is associated with a Module, the name of the module. Unset otherwise.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async values() list[EnumValueTypeDef][source]

The values of the enum.

class dagger.EnumTypeDefID

Bases: Scalar

The EnumTypeDefID scalar type represents an identifier for an object of type EnumTypeDef.

class dagger.EnumValueTypeDef(ctx: Context)

Bases: Type

A definition of a value in a custom enum defined in a Module.

async description() str[source]

A doc string for the enum value, if any.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() EnumValueTypeDefID[source]

A unique identifier for this EnumValueTypeDef.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The EnumValueTypeDefID scalar type represents an identifier for an object of type EnumValueTypeDef.

Return type:

EnumValueTypeDefID

Raises:
async name() str[source]

The name of the enum value.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
source_map() SourceMap[source]

The location of this enum value declaration.

class dagger.EnumValueTypeDefID

Bases: Scalar

The EnumValueTypeDefID scalar type represents an identifier for an object of type EnumValueTypeDef.

class dagger.Env(ctx: Context)

Bases: Type

async id() EnvID[source]

A unique identifier for this Env.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The EnvID scalar type represents an identifier for an object of type Env.

Return type:

EnvID

Raises:
input(name: str) Binding[source]

retrieve an input value by name

async inputs() list[Binding][source]

return all input values for the environment

output(name: str) Binding[source]

retrieve an output value by name

async outputs() list[Binding][source]

return all output values for the environment

with_(cb: Callable[[Env], Env]) Env[source]

Call the provided callable with current Env.

This is useful for reusability and readability by not breaking the calling chain.

with_cache_volume_input(name: str, value: CacheVolume, description: str) Self[source]

Create or update a binding of type CacheVolume in the environment

Parameters:
  • name – The name of the binding

  • value – The CacheVolume value to assign to the binding

  • description – The purpose of the input

with_cache_volume_output(name: str, description: str) Self[source]

Declare a desired CacheVolume output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_container_input(name: str, value: Container, description: str) Self[source]

Create or update a binding of type Container in the environment

Parameters:
  • name – The name of the binding

  • value – The Container value to assign to the binding

  • description – The purpose of the input

with_container_output(name: str, description: str) Self[source]

Declare a desired Container output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_directory_input(name: str, value: Directory, description: str) Self[source]

Create or update a binding of type Directory in the environment

Parameters:
  • name – The name of the binding

  • value – The Directory value to assign to the binding

  • description – The purpose of the input

with_directory_output(name: str, description: str) Self[source]

Declare a desired Directory output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_env_input(name: str, value: Self, description: str) Self[source]

Create or update a binding of type Env in the environment

Parameters:
  • name – The name of the binding

  • value – The Env value to assign to the binding

  • description – The purpose of the input

with_env_output(name: str, description: str) Self[source]

Declare a desired Env output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_file_input(name: str, value: File, description: str) Self[source]

Create or update a binding of type File in the environment

Parameters:
  • name – The name of the binding

  • value – The File value to assign to the binding

  • description – The purpose of the input

with_file_output(name: str, description: str) Self[source]

Declare a desired File output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_git_ref_input(name: str, value: GitRef, description: str) Self[source]

Create or update a binding of type GitRef in the environment

Parameters:
  • name – The name of the binding

  • value – The GitRef value to assign to the binding

  • description – The purpose of the input

with_git_ref_output(name: str, description: str) Self[source]

Declare a desired GitRef output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_git_repository_input(name: str, value: GitRepository, description: str) Self[source]

Create or update a binding of type GitRepository in the environment

Parameters:
  • name – The name of the binding

  • value – The GitRepository value to assign to the binding

  • description – The purpose of the input

with_git_repository_output(name: str, description: str) Self[source]

Declare a desired GitRepository output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_llm_input(name: str, value: LLM, description: str) Self[source]

Create or update a binding of type LLM in the environment

Parameters:
  • name – The name of the binding

  • value – The LLM value to assign to the binding

  • description – The purpose of the input

with_llm_output(name: str, description: str) Self[source]

Declare a desired LLM output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_module_config_client_input(name: str, value: ModuleConfigClient, description: str) Self[source]

Create or update a binding of type ModuleConfigClient in the environment

Parameters:
  • name – The name of the binding

  • value – The ModuleConfigClient value to assign to the binding

  • description – The purpose of the input

with_module_config_client_output(name: str, description: str) Self[source]

Declare a desired ModuleConfigClient output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_module_input(name: str, value: Module, description: str) Self[source]

Create or update a binding of type Module in the environment

Parameters:
  • name – The name of the binding

  • value – The Module value to assign to the binding

  • description – The purpose of the input

with_module_output(name: str, description: str) Self[source]

Declare a desired Module output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_module_source_input(name: str, value: ModuleSource, description: str) Self[source]

Create or update a binding of type ModuleSource in the environment

Parameters:
  • name – The name of the binding

  • value – The ModuleSource value to assign to the binding

  • description – The purpose of the input

with_module_source_output(name: str, description: str) Self[source]

Declare a desired ModuleSource output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_secret_input(name: str, value: Secret, description: str) Self[source]

Create or update a binding of type Secret in the environment

Parameters:
  • name – The name of the binding

  • value – The Secret value to assign to the binding

  • description – The purpose of the input

with_secret_output(name: str, description: str) Self[source]

Declare a desired Secret output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_service_input(name: str, value: Service, description: str) Self[source]

Create or update a binding of type Service in the environment

Parameters:
  • name – The name of the binding

  • value – The Service value to assign to the binding

  • description – The purpose of the input

with_service_output(name: str, description: str) Self[source]

Declare a desired Service output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_socket_input(name: str, value: Socket, description: str) Self[source]

Create or update a binding of type Socket in the environment

Parameters:
  • name – The name of the binding

  • value – The Socket value to assign to the binding

  • description – The purpose of the input

with_socket_output(name: str, description: str) Self[source]

Declare a desired Socket output to be assigned in the environment

Parameters:
  • name – The name of the binding

  • description – A description of the desired value of the binding

with_string_input(name: str, value: str, description: str) Self[source]

Create or update an input value of type string

Parameters:
  • name – The name of the binding

  • value – The string value to assign to the binding

  • description – The description of the input

with_string_output(name: str, description: str) Self[source]

Create or update an input value of type string

Parameters:
  • name – The name of the binding

  • description – The description of the output

class dagger.EnvID

Bases: Scalar

The EnvID scalar type represents an identifier for an object of type Env.

class dagger.EnvVariable(ctx: Context)

Bases: Type

An environment variable name and value.

async id() EnvVariableID[source]

A unique identifier for this EnvVariable.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The EnvVariableID scalar type represents an identifier for an object of type EnvVariable.

Return type:

EnvVariableID

Raises:
async name() str[source]

The environment variable name.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async value() str[source]

The environment variable value.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.EnvVariableID

Bases: Scalar

The EnvVariableID scalar type represents an identifier for an object of type EnvVariable.

class dagger.Error(ctx: Context)

Bases: Type

async id() ErrorID[source]

A unique identifier for this Error.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The ErrorID scalar type represents an identifier for an object of type Error.

Return type:

ErrorID

Raises:
async message() str[source]

A description of the error.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async values() list[ErrorValue][source]

The extensions of the error.

with_(cb: Callable[[Error], Error]) Error[source]

Call the provided callable with current Error.

This is useful for reusability and readability by not breaking the calling chain.

with_value(name: str, value: JSON) Self[source]

Add a value to the error.

Parameters:
  • name – The name of the value.

  • value – The value to store on the error.

class dagger.ErrorID

Bases: Scalar

The ErrorID scalar type represents an identifier for an object of type Error.

class dagger.ErrorValue(ctx: Context)

Bases: Type

async id() ErrorValueID[source]

A unique identifier for this ErrorValue.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The ErrorValueID scalar type represents an identifier for an object of type ErrorValue.

Return type:

ErrorValueID

Raises:
async name() str[source]

The name of the value.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async value() JSON[source]

The value.

Returns:

An arbitrary JSON-encoded value.

Return type:

JSON

Raises:
class dagger.ErrorValueID

Bases: Scalar

The ErrorValueID scalar type represents an identifier for an object of type ErrorValue.

class dagger.FieldTypeDef(ctx: Context)

Bases: Type

A definition of a field on a custom object defined in a Module. A field on an object has a static value, as opposed to a function on an object whose value is computed by invoking code (and can accept arguments).

async description() str[source]

A doc string for the field, if any.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() FieldTypeDefID[source]

A unique identifier for this FieldTypeDef.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The FieldTypeDefID scalar type represents an identifier for an object of type FieldTypeDef.

Return type:

FieldTypeDefID

Raises:
async name() str[source]

The name of the field in lowerCamelCase format.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
source_map() SourceMap[source]

The location of this field declaration.

type_def() TypeDef[source]

The type of the field.

class dagger.FieldTypeDefID

Bases: Scalar

The FieldTypeDefID scalar type represents an identifier for an object of type FieldTypeDef.

class dagger.File(ctx: Context)

Bases: Type

A file.

async contents() str[source]

Retrieves the contents of the file.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async digest(*, exclude_metadata: bool | None = False) str[source]

Return the file’s digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.

Parameters:

exclude_metadata – If true, exclude metadata from the digest.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async export(path: str, *, allow_parent_dir_path: bool | None = False) str[source]

Writes the file to a file path on the host.

Parameters:
  • path – Location of the written directory (e.g., “output.txt”).

  • allow_parent_dir_path – If allowParentDirPath is true, the path argument can be a directory path, in which case the file will be created in that directory.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() FileID[source]

A unique identifier for this File.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The FileID scalar type represents an identifier for an object of type File.

Return type:

FileID

Raises:
async name() str[source]

Retrieves the name of the file.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async size() int[source]

Retrieves the size of the file, in bytes.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async sync() Self[source]

Force evaluation in the engine.

Raises:
with_(cb: Callable[[File], File]) File[source]

Call the provided callable with current File.

This is useful for reusability and readability by not breaking the calling chain.

with_name(name: str) Self[source]

Retrieves this file with its name set to the given name.

Parameters:

name – Name to set file to.

with_timestamps(timestamp: int) Self[source]

Retrieves this file with its created/modified timestamps set to the given time.

Parameters:

timestamp – Timestamp to set dir/files in. Formatted in seconds following Unix epoch (e.g., 1672531199).

class dagger.FileID

Bases: Scalar

The FileID scalar type represents an identifier for an object of type File.

class dagger.Function(ctx: Context)

Bases: Type

Function represents a resolver provided by a Module. A function always evaluates against a parent object and is given a set of named arguments.

async args() list[FunctionArg][source]

Arguments accepted by the function, if any.

async description() str[source]

A doc string for the function, if any.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() FunctionID[source]

A unique identifier for this Function.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The FunctionID scalar type represents an identifier for an object of type Function.

Return type:

FunctionID

Raises:
async name() str[source]

The name of the function.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
return_type() TypeDef[source]

The type returned by the function.

source_map() SourceMap[source]

The location of this function declaration.

with_(cb: Callable[[Function], Function]) Function[source]

Call the provided callable with current Function.

This is useful for reusability and readability by not breaking the calling chain.

with_arg(name: str, type_def: TypeDef, *, description: str | None = '', default_value: JSON | None = None, default_path: str | None = '', ignore: list[str] | None = None, source_map: SourceMap | None = None) Self[source]

Returns the function with the provided argument

Parameters:
  • name – The name of the argument

  • type_def – The type of the argument

  • description – A doc string for the argument, if any

  • default_value – A default value to use for this argument if not explicitly set by the caller, if any

  • default_path – If the argument is a Directory or File type, default to load path from context directory, relative to root directory.

  • ignore – Patterns to ignore when loading the contextual argument value.

  • source_map – The source map for the argument definition.

with_description(description: str) Self[source]

Returns the function with the given doc string.

Parameters:

description – The doc string to set.

with_source_map(source_map: SourceMap) Self[source]

Returns the function with the given source map.

Parameters:

source_map – The source map for the function definition.

class dagger.FunctionArg(ctx: Context)

Bases: Type

An argument accepted by a function. This is a specification for an argument at function definition time, not an argument passed at function call time.

async default_path() str[source]

Only applies to arguments of type File or Directory. If the argument is not set, load it from the given path in the context directory

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async default_value() JSON[source]

A default value to use for this argument when not explicitly set by the caller, if any.

Returns:

An arbitrary JSON-encoded value.

Return type:

JSON

Raises:
async description() str[source]

A doc string for the argument, if any.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() FunctionArgID[source]

A unique identifier for this FunctionArg.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The FunctionArgID scalar type represents an identifier for an object of type FunctionArg.

Return type:

FunctionArgID

Raises:
async ignore() list[str][source]

Only applies to arguments of type Directory. The ignore patterns are applied to the input directory, and matching entries are filtered out, in a cache-efficient manner.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
async name() str[source]

The name of the argument in lowerCamelCase format.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
source_map() SourceMap[source]

The location of this arg declaration.

type_def() TypeDef[source]

The type of the argument.

class dagger.FunctionArgID

Bases: Scalar

The FunctionArgID scalar type represents an identifier for an object of type FunctionArg.

class dagger.FunctionCall(ctx: Context)

Bases: Type

An active function call.

async id() FunctionCallID[source]

A unique identifier for this FunctionCall.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The FunctionCallID scalar type represents an identifier for an object of type FunctionCall.

Return type:

FunctionCallID

Raises:
async input_args() list[FunctionCallArgValue][source]

The argument values the function is being invoked with.

async name() str[source]

The name of the function being called.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async parent() JSON[source]

The value of the parent object of the function being called. If the function is top-level to the module, this is always an empty object.

Returns:

An arbitrary JSON-encoded value.

Return type:

JSON

Raises:
async parent_name() str[source]

The name of the parent object of the function being called. If the function is top-level to the module, this is the name of the module.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async return_error(error: Error) Void | None[source]

Return an error from the function.

Parameters:

error – The error to return.

Returns:

The absence of a value. A Null Void is used as a placeholder for resolvers that do not return anything.

Return type:

Void | None

Raises:
async return_value(value: JSON) Void | None[source]

Set the return value of the function call to the provided value.

Parameters:

value – JSON serialization of the return value.

Returns:

The absence of a value. A Null Void is used as a placeholder for resolvers that do not return anything.

Return type:

Void | None

Raises:
class dagger.FunctionCallArgValue(ctx: Context)

Bases: Type

A value passed as a named argument to a function call.

async id() FunctionCallArgValueID[source]

A unique identifier for this FunctionCallArgValue.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The FunctionCallArgValueID scalar type represents an identifier for an object of type FunctionCallArgValue.

Return type:

FunctionCallArgValueID

Raises:
async name() str[source]

The name of the argument.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async value() JSON[source]

The value of the argument represented as a JSON serialized string.

Returns:

An arbitrary JSON-encoded value.

Return type:

JSON

Raises:
class dagger.FunctionCallArgValueID

Bases: Scalar

The FunctionCallArgValueID scalar type represents an identifier for an object of type FunctionCallArgValue.

class dagger.FunctionCallID

Bases: Scalar

The FunctionCallID scalar type represents an identifier for an object of type FunctionCall.

class dagger.FunctionID

Bases: Scalar

The FunctionID scalar type represents an identifier for an object of type Function.

class dagger.GeneratedCode(ctx: Context)

Bases: Type

The result of running an SDK’s codegen.

code() Directory[source]

The directory containing the generated code.

async id() GeneratedCodeID[source]

A unique identifier for this GeneratedCode.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The GeneratedCodeID scalar type represents an identifier for an object of type GeneratedCode.

Return type:

GeneratedCodeID

Raises:
async vcs_generated_paths() list[str][source]

List of paths to mark generated in version control (i.e. .gitattributes).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
async vcs_ignored_paths() list[str][source]

List of paths to ignore in version control (i.e. .gitignore).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
with_(cb: Callable[[GeneratedCode], GeneratedCode]) GeneratedCode[source]

Call the provided callable with current GeneratedCode.

This is useful for reusability and readability by not breaking the calling chain.

with_vcs_generated_paths(paths: list[str]) Self[source]

Set the list of paths to mark generated in version control.

with_vcs_ignored_paths(paths: list[str]) Self[source]

Set the list of paths to ignore in version control.

class dagger.GeneratedCodeID

Bases: Scalar

The GeneratedCodeID scalar type represents an identifier for an object of type GeneratedCode.

class dagger.GitRef(ctx: Context)

Bases: Type

A git ref (tag, branch, or commit).

async commit() str[source]

The resolved commit id at this ref.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() GitRefID[source]

A unique identifier for this GitRef.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The GitRefID scalar type represents an identifier for an object of type GitRef.

Return type:

GitRefID

Raises:
async ref() str[source]

The resolved ref name at this ref.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
tree(*, discard_git_dir: bool | None = False, depth: int | None = 1) Directory[source]

The filesystem tree at this ref.

Parameters:
  • discard_git_dir – Set to true to discard .git directory.

  • depth – The depth of the tree to fetch.

class dagger.GitRefID

Bases: Scalar

The GitRefID scalar type represents an identifier for an object of type GitRef.

class dagger.GitRepository(ctx: Context)

Bases: Type

A git repository.

branch(name: str) GitRef[source]

Returns details of a branch.

Parameters:

name – Branch’s name (e.g., “main”).

async branches(*, patterns: list[str] | None = None) list[str][source]

branches that match any of the given glob patterns.

Parameters:

patterns – Glob patterns (e.g., “refs/tags/v*”).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
commit(id: str) GitRef[source]

Returns details of a commit.

Parameters:

id – Identifier of the commit (e.g., “b6315d8f2810962c601af73f86831f6866ea798b”).

head() GitRef[source]

Returns details for HEAD.

async id() GitRepositoryID[source]

A unique identifier for this GitRepository.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The GitRepositoryID scalar type represents an identifier for an object of type GitRepository.

Return type:

GitRepositoryID

Raises:
ref(name: str) GitRef[source]

Returns details of a ref.

Parameters:

name – Ref’s name (can be a commit identifier, a tag name, a branch name, or a fully-qualified ref).

tag(name: str) GitRef[source]

Returns details of a tag.

Parameters:

name – Tag’s name (e.g., “v0.3.9”).

async tags(*, patterns: list[str] | None = None) list[str][source]

tags that match any of the given glob patterns.

Parameters:

patterns – Glob patterns (e.g., “refs/tags/v*”).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
with_(cb: Callable[[GitRepository], GitRepository]) GitRepository[source]

Call the provided callable with current GitRepository.

This is useful for reusability and readability by not breaking the calling chain.

with_auth_header(header: Secret) Self[source]

Header to authenticate the remote with.

Deprecated

Use “httpAuthHeader” in the constructor instead.

Parameters:

header – Secret used to populate the Authorization HTTP header

with_auth_token(token: Secret) Self[source]

Token to authenticate the remote with.

Deprecated

Use “httpAuthToken” in the constructor instead.

Parameters:

token – Secret used to populate the password during basic HTTP Authorization

class dagger.GitRepositoryID

Bases: Scalar

The GitRepositoryID scalar type represents an identifier for an object of type GitRepository.

class dagger.Host(ctx: Context)

Bases: Type

Information about the host environment.

directory(path: str, *, exclude: list[str] | None = None, include: list[str] | None = None, no_cache: bool | None = False) Directory[source]

Accesses a directory on the host.

Parameters:
  • path – Location of the directory to access (e.g., “.”).

  • exclude – Exclude artifacts that match the given pattern (e.g., [“node_modules/”, “.git*”]).

  • include – Include only artifacts that match the given pattern (e.g., [“app/”, “package.*”]).

  • no_cache – If true, the directory will always be reloaded from the host.

file(path: str, *, no_cache: bool | None = False) File[source]

Accesses a file on the host.

Parameters:
  • path – Location of the file to retrieve (e.g., “README.md”).

  • no_cache – If true, the file will always be reloaded from the host.

async id() HostID[source]

A unique identifier for this Host.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The HostID scalar type represents an identifier for an object of type Host.

Return type:

HostID

Raises:
service(ports: list[PortForward], *, host: str | None = 'localhost') Service[source]

Creates a service that forwards traffic to a specified address via the host.

Parameters:
  • ports – Ports to expose via the service, forwarding through the host network. If a port’s frontend is unspecified or 0, it defaults to the same as the backend port. An empty set of ports is not valid; an error will be returned.

  • host – Upstream host to forward traffic to.

set_secret_file(name: str, path: str) Secret[source]

Sets a secret given a user-defined name and the file path on the host, and returns the secret.

The file is limited to a size of 512000 bytes.

Deprecated

setSecretFile is superceded by use of the secret API with file:// URIs

Parameters:
  • name – The user defined name for this secret.

  • path – Location of the file to set as a secret.

tunnel(service: Service, *, native: bool | None = False, ports: list[PortForward] | None = None) Service[source]

Creates a tunnel that forwards traffic from the host to a service.

Parameters:
  • service – Service to send traffic from the tunnel.

  • native – Map each service port to the same port on the host, as if the service were running natively. Note: enabling may result in port conflicts.

  • ports – Configure explicit port forwarding rules for the tunnel. If a port’s frontend is unspecified or 0, a random port will be chosen by the host. If no ports are given, all of the service’s ports are forwarded. If native is true, each port maps to the same port on the host. If native is false, each port maps to a random port chosen by the host. If ports are given and native is true, the ports are additive.

unix_socket(path: str) Socket[source]

Accesses a Unix socket on the host.

Parameters:

path – Location of the Unix socket (e.g., “/var/run/docker.sock”).

class dagger.HostID

Bases: Scalar

The HostID scalar type represents an identifier for an object of type Host.

class dagger.ImageLayerCompression(*values)

Bases: Enum

Compression algorithm to use for image layers.

EStarGZ = 'EStarGZ'
Gzip = 'Gzip'
Uncompressed = 'Uncompressed'
Zstd = 'Zstd'
class dagger.ImageMediaTypes(*values)

Bases: Enum

Mediatypes to use in published or exported image metadata.

DockerMediaTypes = 'DockerMediaTypes'
OCIMediaTypes = 'OCIMediaTypes'
class dagger.InputTypeDef(ctx: Context)

Bases: Type

A graphql input type, which is essentially just a group of named args. This is currently only used to represent pre-existing usage of graphql input types in the core API. It is not used by user modules and shouldn’t ever be as user module accept input objects via their id rather than graphql input types.

async fields() list[FieldTypeDef][source]

Static fields defined on this input object, if any.

async id() InputTypeDefID[source]

A unique identifier for this InputTypeDef.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The InputTypeDefID scalar type represents an identifier for an object of type InputTypeDef.

Return type:

InputTypeDefID

Raises:
async name() str[source]

The name of the input object.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.InputTypeDefID

Bases: Scalar

The InputTypeDefID scalar type represents an identifier for an object of type InputTypeDef.

class dagger.InterfaceTypeDef(ctx: Context)

Bases: Type

A definition of a custom interface defined in a Module.

async description() str[source]

The doc string for the interface, if any.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async functions() list[Function][source]

Functions defined on this interface, if any.

async id() InterfaceTypeDefID[source]

A unique identifier for this InterfaceTypeDef.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The InterfaceTypeDefID scalar type represents an identifier for an object of type InterfaceTypeDef.

Return type:

InterfaceTypeDefID

Raises:
async name() str[source]

The name of the interface.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
source_map() SourceMap[source]

The location of this interface declaration.

async source_module_name() str[source]

If this InterfaceTypeDef is associated with a Module, the name of the module. Unset otherwise.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.InterfaceTypeDefID

Bases: Scalar

The InterfaceTypeDefID scalar type represents an identifier for an object of type InterfaceTypeDef.

class dagger.JSON

Bases: Scalar

An arbitrary JSON-encoded value.

class dagger.LLM(ctx: Context)

Bases: Type

attempt(number: int) Self[source]

create a branch in the LLM’s history

bind_result(name: str) Binding[source]

returns the type of the current state

env() Env[source]

return the LLM’s current environment

async history() list[str][source]

return the llm message history

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

list[str]

Raises:
async history_json() JSON[source]

return the raw llm message history as json

Returns:

An arbitrary JSON-encoded value.

Return type:

JSON

Raises:
async id() LLMID[source]

A unique identifier for this LLM.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The LLMID scalar type represents an identifier for an object of type LLM.

Return type:

LLMID

Raises:
async last_reply() str[source]

return the last llm reply from the history

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
loop() Self[source]

synchronize LLM state

async model() str[source]

return the model used by the llm

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async provider() str[source]

return the provider used by the llm

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async sync() Self[source]

synchronize LLM state

Raises:
token_usage() LLMTokenUsage[source]

returns the token usage of the current state

async tools() str[source]

print documentation for available tools

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
with_(cb: Callable[[LLM], LLM]) LLM[source]

Call the provided callable with current LLM.

This is useful for reusability and readability by not breaking the calling chain.

with_env(env: Env) Self[source]

allow the LLM to interact with an environment via MCP

with_model(model: str) Self[source]

swap out the llm model

Parameters:

model – The model to use

with_prompt(prompt: str) Self[source]

append a prompt to the llm context

Parameters:

prompt – The prompt to send

with_prompt_file(file: File) Self[source]

append the contents of a file to the llm context

Parameters:

file – The file to read the prompt from

with_system_prompt(prompt: str) Self[source]

Add a system prompt to the LLM’s environment

Parameters:

prompt – The system prompt to send

without_default_system_prompt() Self[source]

Disable the default system prompt

class dagger.LLMID

Bases: Scalar

The LLMID scalar type represents an identifier for an object of type LLM.

class dagger.LLMTokenUsage(ctx: Context)

Bases: Type

async cached_token_reads() int[source]
Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async cached_token_writes() int[source]
Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async id() LLMTokenUsageID[source]

A unique identifier for this LLMTokenUsage.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The LLMTokenUsageID scalar type represents an identifier for an object of type LLMTokenUsage.

Return type:

LLMTokenUsageID

Raises:
async input_tokens() int[source]
Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async output_tokens() int[source]
Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async total_tokens() int[source]
Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
class dagger.LLMTokenUsageID

Bases: Scalar

The LLMTokenUsageID scalar type represents an identifier for an object of type LLMTokenUsage.

class dagger.Label(ctx: Context)

Bases: Type

A simple key value object that represents a label.

async id() LabelID[source]

A unique identifier for this Label.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The LabelID scalar type represents an identifier for an object of type Label.

Return type:

LabelID

Raises:
async name() str[source]

The label name.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async value() str[source]

The label value.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.LabelID

Bases: Scalar

The LabelID scalar type represents an identifier for an object of type Label.

class dagger.ListTypeDef(ctx: Context)

Bases: Type

A definition of a list type in a Module.

element_type_def() TypeDef[source]

The type of the elements in the list.

async id() ListTypeDefID[source]

A unique identifier for this ListTypeDef.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The ListTypeDefID scalar type represents an identifier for an object of type ListTypeDef.

Return type:

ListTypeDefID

Raises:
class dagger.ListTypeDefID

Bases: Scalar

The ListTypeDefID scalar type represents an identifier for an object of type ListTypeDef.

class dagger.Module(ctx: Context)

Bases: Type

A Dagger module.

async dependencies() list[Module][source]

The dependencies of the module.

async description() str[source]

The doc string of the module, if any

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async enums() list[TypeDef][source]

Enumerations served by this module.

generated_context_directory() Directory[source]

The generated files and directories made on top of the module source’s context directory.

async id() ModuleID[source]

A unique identifier for this Module.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The ModuleID scalar type represents an identifier for an object of type Module.

Return type:

ModuleID

Raises:
async interfaces() list[TypeDef][source]

Interfaces served by this module.

async name() str[source]

The name of the module

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async objects() list[TypeDef][source]

Objects served by this module.

runtime() Container[source]

The container that runs the module’s entrypoint. It will fail to execute if the module doesn’t compile.

sdk() SDKConfig[source]

The SDK config used by this module.

async serve(*, include_dependencies: bool | None = None) Void | None[source]

Serve a module’s API in the current session.

Note: this can only be called once per session. In the future, it could return a stream or service to remove the side effect.

Parameters:

include_dependencies – Expose the dependencies of this module to the client

Returns:

The absence of a value. A Null Void is used as a placeholder for resolvers that do not return anything.

Return type:

Void | None

Raises:
source() ModuleSource[source]

The source for the module.

async sync() Self[source]

Forces evaluation of the module, including any loading into the engine and associated validation.

Raises:
with_(cb: Callable[[Module], Module]) Module[source]

Call the provided callable with current Module.

This is useful for reusability and readability by not breaking the calling chain.

with_description(description: str) Self[source]

Retrieves the module with the given description

Parameters:

description – The description to set

with_enum(enum: TypeDef) Self[source]

This module plus the given Enum type and associated values

with_interface(iface: TypeDef) Self[source]

This module plus the given Interface type and associated functions

with_object(object: TypeDef) Self[source]

This module plus the given Object type and associated functions.

class dagger.ModuleConfigClient(ctx: Context)

Bases: Type

The client generated for the module.

async dev() bool | None[source]

If true, generate the client in developer mode.

Returns:

The Boolean scalar type represents true or false.

Return type:

bool | None

Raises:
async directory() str[source]

The directory the client is generated in.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async generator() str[source]

The generator to use

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() ModuleConfigClientID[source]

A unique identifier for this ModuleConfigClient.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The ModuleConfigClientID scalar type represents an identifier for an object of type ModuleConfigClient.

Return type:

ModuleConfigClientID

Raises:
class dagger.ModuleConfigClientID

Bases: Scalar

The ModuleConfigClientID scalar type represents an identifier for an object of type ModuleConfigClient.

class dagger.ModuleID

Bases: Scalar

The ModuleID scalar type represents an identifier for an object of type Module.

class dagger.ModuleSource(ctx: Context)

Bases: Type

The source needed to load and run a module, along with any metadata about the source such as versions/urls/etc.

as_module() Module[source]

Load the source as a module. If this is a local source, the parent directory must have been provided during module source creation

async as_string() str[source]

A human readable ref string representation of this module source.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async clone_ref() str[source]

The ref to clone the root of the git repo from. Only valid for git sources.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async commit() str[source]

The resolved commit of the git repo this source points to.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async config_clients() list[ModuleConfigClient][source]

The clients generated for the module.

async config_exists() bool[source]

Whether an existing dagger.json for the module was found.

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

Raises:
context_directory() Directory[source]

The full directory loaded for the module source, including the source code as a subdirectory.

async dependencies() list[ModuleSource][source]

The dependencies of the module source.

async digest() str[source]

A content-hash of the module source. Module sources with the same digest will output the same generated context and convert into the same module instance.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
directory(path: str) Directory[source]

The directory containing the module configuration and source code (source code may be in a subdir).

Parameters:

path – A subpath from the source directory to select.

async engine_version() str[source]

The engine version of the module.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
generated_context_directory() Directory[source]

The generated files and directories made on top of the module source’s context directory.

async html_repo_url() str[source]

The URL to access the web view of the repository (e.g., GitHub, GitLab, Bitbucket).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async html_url() str[source]

The URL to the source’s git repo in a web browser. Only valid for git sources.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() ModuleSourceID[source]

A unique identifier for this ModuleSource.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The ModuleSourceID scalar type represents an identifier for an object of type ModuleSource.

Return type:

ModuleSourceID

Raises:
async kind() ModuleSourceKind[source]

The kind of module source (currently local, git or dir).

Returns:

The kind of module source.

Return type:

ModuleSourceKind

Raises:
async local_context_directory_path() str[source]

The full absolute path to the context directory on the caller’s host filesystem that this module source is loaded from. Only valid for local module sources.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async module_name() str[source]

The name of the module, including any setting via the withName API.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async module_original_name() str[source]

The original name of the module as read from the module’s dagger.json (or set for the first time with the withName API).

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async original_subpath() str[source]

The original subpath used when instantiating this module source, relative to the context directory.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async pin() str[source]

The pinned version of this module source.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async repo_root_path() str[source]

The import path corresponding to the root of the git repo this source points to. Only valid for git sources.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
sdk() SDKConfig[source]

The SDK configuration of the module.

async source_root_subpath() str[source]

The path, relative to the context directory, that contains the module’s dagger.json.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async source_subpath() str[source]

The path to the directory containing the module’s source code, relative to the context directory.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async sync() Self[source]

Forces evaluation of the module source, including any loading into the engine and associated validation.

Raises:
async version() str[source]

The specified version of the git repo this source points to.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
with_(cb: Callable[[ModuleSource], ModuleSource]) ModuleSource[source]

Call the provided callable with current ModuleSource.

This is useful for reusability and readability by not breaking the calling chain.

with_client(generator: str, output_dir: str, *, dev: bool | None = None) Self[source]

Update the module source with a new client to generate.

Parameters:
  • generator – The generator to use

  • output_dir – The output directory for the generated client.

  • dev – Generate in developer mode

with_dependencies(dependencies: list[ModuleSource]) Self[source]

Append the provided dependencies to the module source’s dependency list.

Parameters:

dependencies – The dependencies to append.

with_engine_version(version: str) Self[source]

Upgrade the engine version of the module to the given value.

Parameters:

version – The engine version to upgrade to.

with_includes(patterns: list[str]) Self[source]

Update the module source with additional include patterns for files+directories from its context that are required for building it

Parameters:

patterns – The new additional include patterns.

with_name(name: str) Self[source]

Update the module source with a new name.

Parameters:

name – The name to set.

with_sdk(source: str) Self[source]

Update the module source with a new SDK.

Parameters:

source – The SDK source to set.

with_source_subpath(path: str) Self[source]

Update the module source with a new source subpath.

Parameters:

path – The path to set as the source subpath. Must be relative to the module source’s source root directory.

with_update_dependencies(dependencies: list[str]) Self[source]

Update one or more module dependencies.

Parameters:

dependencies – The dependencies to update.

without_client(path: str) Self[source]

Remove a client from the module source.

Parameters:

path – The path of the client to remove.

without_dependencies(dependencies: list[str]) Self[source]

Remove the provided dependencies from the module source’s dependency list.

Parameters:

dependencies – The dependencies to remove.

class dagger.ModuleSourceID

Bases: Scalar

The ModuleSourceID scalar type represents an identifier for an object of type ModuleSource.

class dagger.ModuleSourceKind(*values)

Bases: Enum

The kind of module source.

DIR_SOURCE = 'DIR_SOURCE'
GIT_SOURCE = 'GIT_SOURCE'
LOCAL_SOURCE = 'LOCAL_SOURCE'
class dagger.NetworkProtocol(*values)

Bases: Enum

Transport layer network protocol associated to a port.

TCP = 'TCP'
UDP = 'UDP'
class dagger.ObjectTypeDef(ctx: Context)

Bases: Type

A definition of a custom object defined in a Module.

constructor() Function[source]

The function used to construct new instances of this object, if any

async description() str[source]

The doc string for the object, if any.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async fields() list[FieldTypeDef][source]

Static fields defined on this object, if any.

async functions() list[Function][source]

Functions defined on this object, if any.

async id() ObjectTypeDefID[source]

A unique identifier for this ObjectTypeDef.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The ObjectTypeDefID scalar type represents an identifier for an object of type ObjectTypeDef.

Return type:

ObjectTypeDefID

Raises:
async name() str[source]

The name of the object.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
source_map() SourceMap[source]

The location of this object declaration.

async source_module_name() str[source]

If this ObjectTypeDef is associated with a Module, the name of the module. Unset otherwise.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.ObjectTypeDefID

Bases: Scalar

The ObjectTypeDefID scalar type represents an identifier for an object of type ObjectTypeDef.

class dagger.PipelineLabel(name: str, value: str)

Bases: Input

Key value object that represents a pipeline label.

name: str
value: str
class dagger.Platform

Bases: Scalar

The platform config OS and architecture in a Container. The format is [os]/[platform]/[version] (e.g., “darwin/arm64/v7”, “windows/amd64”, “linux/arm64”).

class dagger.Port(ctx: Context)

Bases: Type

A port exposed by a container.

async description() str | None[source]

The port description.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str | None

Raises:
async experimental_skip_healthcheck() bool[source]

Skip the health check when run as a service.

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

Raises:
async id() PortID[source]

A unique identifier for this Port.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The PortID scalar type represents an identifier for an object of type Port.

Return type:

PortID

Raises:
async port() int[source]

The port number.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async protocol() NetworkProtocol[source]

The transport layer protocol.

Returns:

Transport layer network protocol associated to a port.

Return type:

NetworkProtocol

Raises:
class dagger.PortForward(backend: int, frontend: int | None = None, protocol: NetworkProtocol | None = NetworkProtocol.TCP)

Bases: Input

Port forwarding rules for tunneling network traffic.

backend: int
frontend: int | None
protocol: NetworkProtocol | None
class dagger.PortID

Bases: Scalar

The PortID scalar type represents an identifier for an object of type Port.

class dagger.ReturnType(*values)

Bases: Enum

Expected return type of an execution

ANY = 'ANY'
FAILURE = 'FAILURE'
SUCCESS = 'SUCCESS'
class dagger.SDKConfig(ctx: Context)

Bases: Type

The SDK config of the module.

async id() SDKConfigID[source]

A unique identifier for this SDKConfig.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The SDKConfigID scalar type represents an identifier for an object of type SDKConfig.

Return type:

SDKConfigID

Raises:
async source() str[source]

Source of the SDK. Either a name of a builtin SDK or a module source ref string pointing to the SDK’s implementation.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.SDKConfigID

Bases: Scalar

The SDKConfigID scalar type represents an identifier for an object of type SDKConfig.

class dagger.ScalarTypeDef(ctx: Context)

Bases: Type

A definition of a custom scalar defined in a Module.

async description() str[source]

A doc string for the scalar, if any.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() ScalarTypeDefID[source]

A unique identifier for this ScalarTypeDef.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The ScalarTypeDefID scalar type represents an identifier for an object of type ScalarTypeDef.

Return type:

ScalarTypeDefID

Raises:
async name() str[source]

The name of the scalar.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async source_module_name() str[source]

If this ScalarTypeDef is associated with a Module, the name of the module. Unset otherwise.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.ScalarTypeDefID

Bases: Scalar

The ScalarTypeDefID scalar type represents an identifier for an object of type ScalarTypeDef.

class dagger.Secret(ctx: Context)

Bases: Type

A reference to a secret value, which can be handled more safely than the value itself.

async id() SecretID[source]

A unique identifier for this Secret.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The SecretID scalar type represents an identifier for an object of type Secret.

Return type:

SecretID

Raises:
async name() str[source]

The name of this secret.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async plaintext() str[source]

The value of this secret.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async uri() str[source]

The URI of this secret.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.SecretID

Bases: Scalar

The SecretID scalar type represents an identifier for an object of type Secret.

class dagger.Service(ctx: Context)

Bases: Type

A content-addressed service providing TCP connectivity.

async endpoint(*, port: int | None = None, scheme: str | None = '') str[source]

Retrieves an endpoint that clients can use to reach this container.

If no port is specified, the first exposed port is used. If none exist an error is returned.

If a scheme is specified, a URL is returned. Otherwise, a host:port pair is returned.

Parameters:
  • port – The exposed port number for the endpoint

  • scheme – Return a URL with the given scheme, eg. http for http://

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async hostname() str[source]

Retrieves a hostname which can be used by clients to reach this container.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() ServiceID[source]

A unique identifier for this Service.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The ServiceID scalar type represents an identifier for an object of type Service.

Return type:

ServiceID

Raises:
async ports() list[Port][source]

Retrieves the list of ports provided by the service.

async start() Self[source]

Start the service and wait for its health checks to succeed.

Services bound to a Container do not need to be manually started.

Raises:
async stop(*, kill: bool | None = False) Self[source]

Stop the service.

Parameters:

kill – Immediately kill the service without waiting for a graceful exit

Raises:
async up(*, ports: list[PortForward] | None = None, random: bool | None = False) Void | None[source]

Creates a tunnel that forwards traffic from the caller’s network to this service.

Parameters:
  • ports – List of frontend/backend port mappings to forward. Frontend is the port accepting traffic on the host, backend is the service port.

  • random – Bind each tunnel port to a random port on the host.

Returns:

The absence of a value. A Null Void is used as a placeholder for resolvers that do not return anything.

Return type:

Void | None

Raises:
with_(cb: Callable[[Service], Service]) Service[source]

Call the provided callable with current Service.

This is useful for reusability and readability by not breaking the calling chain.

with_hostname(hostname: str) Self[source]

Configures a hostname which can be used by clients within the session to reach this container.

Parameters:

hostname – The hostname to use.

class dagger.ServiceID

Bases: Scalar

The ServiceID scalar type represents an identifier for an object of type Service.

class dagger.Socket(ctx: Context)

Bases: Type

A Unix or TCP/IP socket that can be mounted into a container.

async id() SocketID[source]

A unique identifier for this Socket.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The SocketID scalar type represents an identifier for an object of type Socket.

Return type:

SocketID

Raises:
class dagger.SocketID

Bases: Scalar

The SocketID scalar type represents an identifier for an object of type Socket.

class dagger.SourceMap(ctx: Context)

Bases: Type

Source location information.

async column() int[source]

The column number within the line.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async filename() str[source]

The filename from the module source.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
async id() SourceMapID[source]

A unique identifier for this SourceMap.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The SourceMapID scalar type represents an identifier for an object of type SourceMap.

Return type:

SourceMapID

Raises:
async line() int[source]

The line number within the filename.

Returns:

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.

Return type:

int

Raises:
async module() str[source]

The module dependency this was declared in.

Returns:

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.

Return type:

str

Raises:
class dagger.SourceMapID

Bases: Scalar

The SourceMapID scalar type represents an identifier for an object of type SourceMap.

class dagger.Terminal(ctx: Context)

Bases: Type

An interactive terminal that clients can connect to.

async id() TerminalID[source]

A unique identifier for this Terminal.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The TerminalID scalar type represents an identifier for an object of type Terminal.

Return type:

TerminalID

Raises:
async sync() Self[source]

Forces evaluation of the pipeline in the engine.

It doesn’t run the default command if no exec has been set.

Raises:
class dagger.TerminalID

Bases: Scalar

The TerminalID scalar type represents an identifier for an object of type Terminal.

class dagger.TypeDef(ctx: Context)

Bases: Type

A definition of a parameter or return type in a Module.

as_enum() EnumTypeDef[source]

If kind is ENUM, the enum-specific type definition. If kind is not ENUM, this will be null.

as_input() InputTypeDef[source]

If kind is INPUT, the input-specific type definition. If kind is not INPUT, this will be null.

as_interface() InterfaceTypeDef[source]

If kind is INTERFACE, the interface-specific type definition. If kind is not INTERFACE, this will be null.

as_list() ListTypeDef[source]

If kind is LIST, the list-specific type definition. If kind is not LIST, this will be null.

as_object() ObjectTypeDef[source]

If kind is OBJECT, the object-specific type definition. If kind is not OBJECT, this will be null.

as_scalar() ScalarTypeDef[source]

If kind is SCALAR, the scalar-specific type definition. If kind is not SCALAR, this will be null.

async id() TypeDefID[source]

A unique identifier for this TypeDef.

Note

This is lazily evaluated, no operation is actually run.

Returns:

The TypeDefID scalar type represents an identifier for an object of type TypeDef.

Return type:

TypeDefID

Raises:
async kind() TypeDefKind[source]

The kind of type this is (e.g. primitive, list, object).

Returns:

Distinguishes the different kinds of TypeDefs.

Return type:

TypeDefKind

Raises:
async optional() bool[source]

Whether this type can be set to null. Defaults to false.

Returns:

The Boolean scalar type represents true or false.

Return type:

bool

Raises:
with_(cb: Callable[[TypeDef], TypeDef]) TypeDef[source]

Call the provided callable with current TypeDef.

This is useful for reusability and readability by not breaking the calling chain.

with_constructor(function: Function) Self[source]

Adds a function for constructing a new instance of an Object TypeDef, failing if the type is not an object.

with_enum(name: str, *, description: str | None = '', source_map: SourceMap | None = None) Self[source]

Returns a TypeDef of kind Enum with the provided name.

Note that an enum’s values may be omitted if the intent is only to refer to an enum. This is how functions are able to return their own, or any other circular reference.

Parameters:
  • name – The name of the enum

  • description – A doc string for the enum, if any

  • source_map – The source map for the enum definition.

with_enum_value(value: str, *, description: str | None = '', source_map: SourceMap | None = None) Self[source]

Adds a static value for an Enum TypeDef, failing if the type is not an enum.

Parameters:
  • value – The name of the value in the enum

  • description – A doc string for the value, if any

  • source_map – The source map for the enum value definition.

with_field(name: str, type_def: Self, *, description: str | None = '', source_map: SourceMap | None = None) Self[source]

Adds a static field for an Object TypeDef, failing if the type is not an object.

Parameters:
  • name – The name of the field in the object

  • type_def – The type of the field

  • description – A doc string for the field, if any

  • source_map – The source map for the field definition.

with_function(function: Function) Self[source]

Adds a function for an Object or Interface TypeDef, failing if the type is not one of those kinds.

with_interface(name: str, *, description: str | None = '', source_map: SourceMap | None = None) Self[source]

Returns a TypeDef of kind Interface with the provided name.

with_kind(kind: TypeDefKind) Self[source]

Sets the kind of the type.

with_list_of(element_type: Self) Self[source]

Returns a TypeDef of kind List with the provided type for its elements.

with_object(name: str, *, description: str | None = '', source_map: SourceMap | None = None) Self[source]

Returns a TypeDef of kind Object with the provided name.

Note that an object’s fields and functions may be omitted if the intent is only to refer to an object. This is how functions are able to return their own object, or any other circular reference.

with_optional(optional: bool) Self[source]

Sets whether this type can be set to null.

with_scalar(name: str, *, description: str | None = '') Self[source]

Returns a TypeDef of kind Scalar with the provided name.

class dagger.TypeDefID

Bases: Scalar

The TypeDefID scalar type represents an identifier for an object of type TypeDef.

class dagger.TypeDefKind(*values)

Bases: Enum

Distinguishes the different kinds of TypeDefs.

BOOLEAN_KIND = 'BOOLEAN_KIND'
ENUM_KIND = 'ENUM_KIND'
FLOAT_KIND = 'FLOAT_KIND'
INPUT_KIND = 'INPUT_KIND'
INTEGER_KIND = 'INTEGER_KIND'
INTERFACE_KIND = 'INTERFACE_KIND'
LIST_KIND = 'LIST_KIND'
OBJECT_KIND = 'OBJECT_KIND'
SCALAR_KIND = 'SCALAR_KIND'
STRING_KIND = 'STRING_KIND'
VOID_KIND = 'VOID_KIND'
class dagger.Void

Bases: Scalar

The absence of a value. A Null Void is used as a placeholder for resolvers that do not return anything.