Class StartContainerTask
java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
io.github.pgatzka.docker.task.DockerTask
io.github.pgatzka.docker.task.container.StartContainerTask
- All Implemented Interfaces:
Comparable<org.gradle.api.Task>,org.gradle.api.internal.DynamicObjectAware,org.gradle.api.internal.TaskInternal,org.gradle.api.Named,org.gradle.api.plugins.ExtensionAware,org.gradle.api.Task,org.gradle.util.Configurable<org.gradle.api.Task>
@UntrackedTask(because="Docker daemon side effects must always run")
public abstract class StartContainerTask
extends DockerTask
Starts a Docker container according to its
ContainerSpec.
Pulls the image (subject to the configured PullPolicy), creates the container if it
does not yet exist, starts it, and blocks until the configured Waitable readiness
strategy is satisfied.
Idempotent against re-runs: an existing running container is left alone, and a stopped
container with the same name is reused rather than recreated. Marked UntrackedTask
because the daemon side effect must always run.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gradle.api.Named
org.gradle.api.Named.Namer -
Field Summary
Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE -
Constructor Summary
ConstructorsConstructorDescriptionInvoked by Gradle's bytecode-decorated subclass; not for direct use. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()Gradle entry point for this task.abstract org.gradle.api.provider.ListProperty<BindMount> MirrorsContainerSpec.bindMounts: host-path bind mounts to attach.abstract org.gradle.api.provider.ListProperty<String> MirrorsContainerSpec.command: override for the image's CMD, or empty to keep the image default.abstract org.gradle.api.provider.Property<String> MirrorsContainerSpec.name: the container name registered on the daemon.Container environment values, mirroringContainerSpec.env.abstract org.gradle.api.provider.Property<String> getImage()MirrorsContainerSpec.image: the image reference (e.g.abstract org.gradle.api.provider.ListProperty<String> MirrorsContainerSpec.networks: declared networks; the first becomes the container's primary network and any remaining ones are attached after creation.getPorts()MirrorsContainerSpec.ports: host port to container port mappings.abstract org.gradle.api.provider.Property<PullPolicy> MirrorsContainerSpec.pullPolicy: when (if ever) to pull the image before start.abstract org.gradle.api.provider.ListProperty<VolumeMount> MirrorsContainerSpec.volumeMounts: named-volume mounts to attach.abstract org.gradle.api.provider.Property<Waitable> MirrorsContainerSpec.waitFor: the readiness strategy applied after start.abstract org.gradle.api.provider.Property<Duration> MirrorsContainerSpec.waitTimeout: maximum time to wait for readiness.Methods inherited from class io.github.pgatzka.docker.task.DockerTask
getDockerServiceMethods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesServiceMethods inherited from class org.gradle.api.internal.AbstractTask
acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, setImpliesSubProjectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.Task
doNotTrackState, notCompatibleWithConfigurationCache
-
Constructor Details
-
StartContainerTask
public StartContainerTask()Invoked by Gradle's bytecode-decorated subclass; not for direct use.
-
-
Method Details
-
getContainerName
MirrorsContainerSpec.name: the container name registered on the daemon.- Returns:
- the container name property
-
getImage
MirrorsContainerSpec.image: the image reference (e.g.postgres:16-alpine).- Returns:
- the image reference property
-
getEnvironment
Container environment values, mirroringContainerSpec.env. Marked@Internalon purpose: env values commonly carry secrets and we do not want them fingerprinted into Gradle's task input snapshot or surfaced in build scans / cache snapshots.- Returns:
- the environment map property
-
getPorts
MirrorsContainerSpec.ports: host port to container port mappings.- Returns:
- the port mappings property
-
getNetworks
MirrorsContainerSpec.networks: declared networks; the first becomes the container's primary network and any remaining ones are attached after creation.- Returns:
- the networks property
-
getCommand
MirrorsContainerSpec.command: override for the image's CMD, or empty to keep the image default.- Returns:
- the command override property
-
getVolumeMounts
MirrorsContainerSpec.volumeMounts: named-volume mounts to attach.- Returns:
- the volume mounts property
-
getBindMounts
MirrorsContainerSpec.bindMounts: host-path bind mounts to attach.- Returns:
- the bind mounts property
-
getWaitFor
MirrorsContainerSpec.waitFor: the readiness strategy applied after start.- Returns:
- the readiness strategy property
-
getWaitTimeout
MirrorsContainerSpec.waitTimeout: maximum time to wait for readiness.- Returns:
- the readiness timeout property
-
getPullPolicy
MirrorsContainerSpec.pullPolicy: when (if ever) to pull the image before start.- Returns:
- the pull policy property
-
execute
public void execute()Gradle entry point for this task. Delegates to the package-privaterun(DockerClient, StartContainerTaskParams, Logger)helper.
-