docker
This module provides Docker-related functionality using Dagger. It supportsbuilding 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.23.0Entrypoint
Return Type
Docker !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| baseHadolintContainer | Container | - | base hadolint container It need contain hadolint |
| buildContainer | Container | - | The external build of container Usefull when need build args |
Example
dagger -m github.com/stuttgart-things/dagger/docker@41f188e601ad0a6cef3e70bf61bc318fe82eec71 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 🔗
lint() 🔗
Lint permit to lint dockerfile image
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| src | Directory ! | - | the src directory |
| dockerfile | String | - | The dockerfile path |
| threshold | String | - | The failure threshold |
Example
dagger -m github.com/stuttgart-things/dagger/docker@41f188e601ad0a6cef3e70bf61bc318fe82eec71 call \
lint --src DIR_PATHfunc (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)
}build() 🔗
Build permit to build image from Dockerfile
Return Type
ImageBuild !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| src | Directory ! | - | the source directory |
| dockerfile | String | "Dockerfile" | The dockerfile path |
| withDirectories | [Directory ! ] | - | Set extra directories |
Example
dagger -m github.com/stuttgart-things/dagger/docker@41f188e601ad0a6cef3e70bf61bc318fe82eec71 call \
build --src DIR_PATHfunc (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)
}getBaseHadolintContainer() 🔗
GetBaseHadolintContainer return the default image for hadolint
Return Type
Container ! Example
dagger -m github.com/stuttgart-things/dagger/docker@41f188e601ad0a6cef3e70bf61bc318fe82eec71 call \
get-base-hadolint-containerfunc (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
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | The source directory |
| repositoryName | String ! | - | The repository name |
| tag | String ! | - | tag |
| registryUsername | Secret | - | The registry username |
| registryPassword | Secret | - | The registry password |
| registryUrl | String ! | - | The registry URL |
| dockerfile | String | "Dockerfile" | The Dockerfile path |
| withDirectories | [Directory ! ] | - | Set extra directories |
Example
dagger -m github.com/stuttgart-things/dagger/docker@41f188e601ad0a6cef3e70bf61bc318fe82eec71 call \
build-and-push --source DIR_PATH --repository-name string --tag string --registry-url stringfunc (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@41f188e601ad0a6cef3e70bf61bc318fe82eec71 call \
build --src DIR_PATH \
get-containerfunc (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
| Name | Type | Default Value | Description |
|---|---|---|---|
| repositoryName | String ! | - | The repository name |
| tag | String ! | - | The tag |
| registryUsername | Secret | - | The registry username |
| registryPassword | Secret | - | The registry password |
| registryUrl | String ! | - | The registry URL |
Example
dagger -m github.com/stuttgart-things/dagger/docker@41f188e601ad0a6cef3e70bf61bc318fe82eec71 call \
build --src DIR_PATH \
push --repository-name string --tag string --registry-url stringfunc (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)
}