Skip to main content

Docker Package

Strongly typed Docker container, image, network, volume, and Buildx commands.

Installation​

dotnet add package ModularPipelines.Docker

Required command-line tool: docker. It must be installed and available on PATH when the pipeline runs.

Context entry points​

Use the discoverable context.Tools surface from a module:

  • context.Tools.Docker

Module example​

using ModularPipelines;
using ModularPipelines.Docker.Options;

public class UseDockerModule : Module<CommandResult>
{
protected override async Task<CommandResult> ExecuteAsync(
IModuleContext context,
CancellationToken cancellationToken)
{
return await context.Tools.Docker.InfoAsync(
new DockerInfoOptions(),
cancellationToken: cancellationToken);
}
}

The package exposes generated options records for its supported CLI commands.

Docker client global options​

Every generated Docker command inherits client settings from DockerOptions. For example:

using ModularPipelines.Docker.Options;

var options = new DockerInfoOptions
{
Context = "remote",
Debug = true,
};

await context.Tools.Docker.InfoAsync(options, cancellationToken: cancellationToken);

The global settings appear before the subcommand: docker --context=remote --debug info. Client configuration, daemon host, logging, and TLS options use the same inherited surface. Help/version actions are not inherited settings.

Global and command-specific names​

A command or plugin can use the same option name for a different purpose. Those settings remain independent: Context selects the Docker client context, while BuildxContext on DockerBuildxCreateOptions is the command's context/endpoint operand. Similarly, Buildx-specific debug options remain command options rather than replacing Docker's global Debug setting.

In V4, command members that collide with a new global property receive a scoped name based on the command scope. The following mappings apply to this generated Docker snapshot:

Command scopePrevious memberV4 command member
docker build, docker buildxDebugCliDebug
Direct docker buildx subcommands, including build, create, history, dap, imagetools, and policyDebugBuildxDebug
docker buildx dap buildDebugDapDebug
Direct docker buildx history subcommandsDebugHistoryDebug
docker buildx history inspect attachmentDebugInspectDebug
docker image buildDebugImageDebug
docker buildx imagetools create and inspectDebugImageToolsDebug
docker buildx policy eval and testDebugPolicyDebug
docker buildx createContext operandBuildxContext
docker context create, export, import, inspect, rm, update, and useContext operandContextContext

The operand rename also applies to named constructor arguments and deconstruction. For example, remove the named context with new DockerContextRmOptions(ContextContext: ["staging"]). Setting inherited Context = "staging" instead selects the Docker client's context; it does not supply the context name to remove.

The generated Docker reference lists each command's options record. Use the scoped members above for command-specific values and the inherited Context or Debug only for Docker client settings.