Dagger
Search

docker

This module provides Docker-related functionality using Dagger. It supports
building Docker images (optionally with extra directories), performing lint
checks with Hadolint, and pushing built images to a container registry.

The module allows you to inject a custom base container for Hadolint, or
a custom container for advanced build scenarios that require specific
build arguments or tooling.

Typical usage includes:
- Building a Docker image from a provided source and Dockerfile
- Optionally attaching extra directories to the build context
- Authenticating and pushing the image to a Docker registry

This module is designed to be used as part of a CI/CD pipeline, either via
the Dagger CLI or any supported Dagger SDK.

Installation

dagger install github.com/stuttgart-things/dagger/docker@v0.22.0

Entrypoint

Return Type
Docker !
Arguments
NameTypeDefault ValueDescription
baseHadolintContainerContainer -base hadolint container It need contain hadolint
buildContainerContainer -The external build of container Usefull when need build args
Example
dagger -m github.com/stuttgart-things/dagger/docker@2820e73fb4c0dc247fb7f369194859e9dcb81691 call \
func (m *MyModule) Example() *dagger.Docker  {
	return dag.
			Docker()
}
@function
def example() -> dagger.Docker:
	return (
		dag.docker()
	)
@func()
example(): Docker {
	return dag
		.docker()
}

Types

Docker 🔗

build() 🔗

Build permit to build image from Dockerfile

Return Type
ImageBuild !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-the source directory
dockerfileString "Dockerfile"The dockerfile path
withDirectories[Directory ! ] -Set extra directories
Example
dagger -m github.com/stuttgart-things/dagger/docker@2820e73fb4c0dc247fb7f369194859e9dcb81691 call \
 build --src DIR_PATH
func (m *MyModule) Example(src *dagger.Directory) *dagger.DockerImageBuild  {
	return dag.
			Docker().
			Build(src)
}
@function
def example(src: dagger.Directory) -> dagger.DockerImageBuild:
	return (
		dag.docker()
		.build(src)
	)
@func()
example(src: Directory): DockerImageBuild {
	return dag
		.docker()
		.build(src)
}

lint() 🔗

Lint permit to lint dockerfile image

Return Type
String !
Arguments
NameTypeDefault ValueDescription
srcDirectory !-the src directory
dockerfileString -The dockerfile path
thresholdString -The failure threshold
Example
dagger -m github.com/stuttgart-things/dagger/docker@2820e73fb4c0dc247fb7f369194859e9dcb81691 call \
 lint --src DIR_PATH
func (m *MyModule) Example(ctx context.Context, src *dagger.Directory) string  {
	return dag.
			Docker().
			Lint(ctx, src)
}
@function
async def example(src: dagger.Directory) -> str:
	return await (
		dag.docker()
		.lint(src)
	)
@func()
async example(src: Directory): Promise<string> {
	return dag
		.docker()
		.lint(src)
}

getBaseHadolintContainer() 🔗

GetBaseHadolintContainer return the default image for hadolint

Return Type
Container !
Example
dagger -m github.com/stuttgart-things/dagger/docker@2820e73fb4c0dc247fb7f369194859e9dcb81691 call \
 get-base-hadolint-container
func (m *MyModule) Example() *dagger.Container  {
	return dag.
			Docker().
			GetBaseHadolintContainer()
}
@function
def example() -> dagger.Container:
	return (
		dag.docker()
		.get_base_hadolint_container()
	)
@func()
example(): Container {
	return dag
		.docker()
		.getBaseHadolintContainer()
}

buildAndPush() 🔗

Return Type
String !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-The source directory
repositoryNameString !-The repository name
tagString !-tag
registryUsernameSecret -The registry username
registryPasswordSecret -The registry password
registryUrlString !-The registry URL
dockerfileString "Dockerfile"The Dockerfile path
withDirectories[Directory ! ] -Set extra directories
Example
dagger -m github.com/stuttgart-things/dagger/docker@2820e73fb4c0dc247fb7f369194859e9dcb81691 call \
 build-and-push --source DIR_PATH --repository-name string --tag string --registry-url string
func (m *MyModule) Example(ctx context.Context, source *dagger.Directory, repositoryName string, tag string, registryUrl string) string  {
	return dag.
			Docker().
			BuildAndPush(ctx, source, repositoryName, tag, registryUrl)
}
@function
async def example(source: dagger.Directory, repository_name: str, tag: str, registry_url: str) -> str:
	return await (
		dag.docker()
		.build_and_push(source, repository_name, tag, registry_url)
	)
@func()
async example(source: Directory, repositoryName: string, tag: string, registryUrl: string): Promise<string> {
	return dag
		.docker()
		.buildAndPush(source, repositoryName, tag, registryUrl)
}

ImageBuild 🔗

getContainer() 🔗

GetContainer permit to get the container

Return Type
Container !
Example
dagger -m github.com/stuttgart-things/dagger/docker@2820e73fb4c0dc247fb7f369194859e9dcb81691 call \
 build --src DIR_PATH \
 get-container
func (m *MyModule) Example(src *dagger.Directory) *dagger.Container  {
	return dag.
			Docker().
			Build(src).
			GetContainer()
}
@function
def example(src: dagger.Directory) -> dagger.Container:
	return (
		dag.docker()
		.build(src)
		.get_container()
	)
@func()
example(src: Directory): Container {
	return dag
		.docker()
		.build(src)
		.getContainer()
}

push() 🔗

Push permits pushing an image to a registry, with support for insecure registries

Return Type
String !
Arguments
NameTypeDefault ValueDescription
repositoryNameString !-The repository name
tagString !-The tag
registryUsernameSecret -The registry username
registryPasswordSecret -The registry password
registryUrlString !-The registry URL
Example
dagger -m github.com/stuttgart-things/dagger/docker@2820e73fb4c0dc247fb7f369194859e9dcb81691 call \
 build --src DIR_PATH \
 push --repository-name string --tag string --registry-url string
func (m *MyModule) Example(ctx context.Context, src *dagger.Directory, repositoryName string, tag string, registryUrl string) string  {
	return dag.
			Docker().
			Build(src).
			Push(ctx, repositoryName, tag, registryUrl)
}
@function
async def example(src: dagger.Directory, repository_name: str, tag: str, registry_url: str) -> str:
	return await (
		dag.docker()
		.build(src)
		.push(repository_name, tag, registry_url)
	)
@func()
async example(src: Directory, repositoryName: string, tag: string, registryUrl: string): Promise<string> {
	return dag
		.docker()
		.build(src)
		.push(repositoryName, tag, registryUrl)
}