Class ContainerSpec
java.lang.Object
io.github.pgatzka.docker.dsl.spec.ContainerSpec
- All Implemented Interfaces:
org.gradle.api.Named
Spec describing a single Docker container the plugin will manage. Created by Gradle's
ObjectFactory once per name registered in docker { containers { register(...) }}.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gradle.api.Named
org.gradle.api.Named.Namer -
Constructor Summary
ConstructorsConstructorDescriptionContainerSpec(String name) Invoked by Gradle'sObjectFactorywhen a container is registered. -
Method Summary
Modifier and TypeMethodDescriptionabstract org.gradle.api.provider.ListProperty<String> Override the image's defaultCMD.abstract org.gradle.api.provider.Property<String> Docker container name to use atdocker runtime.Environment variables passed to the container as-e KEY=VALUEpairs.abstract org.gradle.api.provider.Property<String> getImage()Image reference, e.g.Mutable builder collecting volume and bind mounts declared viamounts(Action).getName()abstract org.gradle.api.provider.ListProperty<String> Names of networks (declared indocker.networks) this container should attach to.getPorts()Published ports: keys are host ports, values are container ports.abstract org.gradle.api.provider.Property<PullPolicy> When the plugin should pull the image.abstract org.gradle.api.provider.Property<Duration> Grace period passed todocker stopbeforeSIGKILL.abstract org.gradle.api.provider.Property<Waitable> getWait()Readiness strategy used by the generatedstart<ContainerName>task.abstract org.gradle.api.provider.Property<Duration> Maximum time the start task waits forgetWait()to succeed before failing.voidConfigure volume and bind mounts for this container.
-
Constructor Details
-
ContainerSpec
Invoked by Gradle'sObjectFactorywhen a container is registered. Sets default conventions:containerNamemirrorsname,waitdefaults toWaitable.none(),waitTimeoutto 60s,stopTimeoutto 10s, andpullPolicytoPullPolicy.IF_NOT_PRESENT.- Parameters:
name- logical container name as registered in the DSL
-
-
Method Details
-
getImage
Image reference, e.g.postgres:16-alpine. Required.- Returns:
- the image property
-
getContainerName
Docker container name to use atdocker runtime. Defaults to the logical DSL name.- Returns:
- the container-name property
-
getEnvironment
Environment variables passed to the container as-e KEY=VALUEpairs.- Returns:
- the environment property
-
getPorts
Published ports: keys are host ports, values are container ports. Example:ports.set(mapOf(5432 to 5432))maps host 5432 → container 5432.- Returns:
- the ports property
-
getNetworks
Names of networks (declared indocker.networks) this container should attach to.- Returns:
- the networks property
-
getCommand
Override the image's defaultCMD. Each entry becomes one argv element.- Returns:
- the command property
-
getWait
Readiness strategy used by the generatedstart<ContainerName>task. Defaults toWaitable.none().- Returns:
- the wait property
-
getWaitTimeout
Maximum time the start task waits forgetWait()to succeed before failing. Defaults to 60 seconds.- Returns:
- the wait-timeout property
-
getStopTimeout
Grace period passed todocker stopbeforeSIGKILL. Defaults to 10 seconds.- Returns:
- the stop-timeout property
-
getPullPolicy
When the plugin should pull the image. Defaults toPullPolicy.IF_NOT_PRESENT.- Returns:
- the pull-policy property
-
mounts
Configure volume and bind mounts for this container.- Parameters:
action- configuration block applied to the sharedMountsbuilder
-
getName
- Specified by:
getNamein interfaceorg.gradle.api.Named
-
getMounts
Mutable builder collecting volume and bind mounts declared viamounts(Action).- Returns:
- the mounts builder
-