Class ContainerExecutor
Executes commands inside a Docker container via 'docker exec'. Provides real-time output streaming and working directory management. Implements ICommandExecutor for seamless switching between local and container execution.
public class ContainerExecutor : CommandExecutorBase, ICommandExecutor
- Inheritance
-
ContainerExecutor
- Implements
- Inherited Members
Constructors
ContainerExecutor(string, IBuildLogger, string)
Creates a new ContainerExecutor.
public ContainerExecutor(string containerId, IBuildLogger logger, string containerWorkDir = "/workspace")
Parameters
containerIdstringDocker container ID or name (container must be running)
loggerIBuildLoggerLogger for output streaming
containerWorkDirstringWorking directory inside the container (default: /workspace)
Methods
IsAvailable(string)
Checks if a command is available inside the container. Uses 'which' command to locate the binary.
public override bool IsAvailable(string command)
Parameters
commandstring
Returns
PrepareProcessStartInfo(string, string[], CommandOptions)
Prepares the ProcessStartInfo for command execution. Subclasses override this to customize the command setup (e.g., wrapping in docker exec).
protected override ProcessStartInfo PrepareProcessStartInfo(string command, string[] args, CommandOptions options)
Parameters
commandstringargsstring[]optionsCommandOptions
Returns
SetHostRootPath(string)
Sets the host root path for path translation. Call this after construction when the host project path is known.
public void SetHostRootPath(string hostRootPath)
Parameters
hostRootPathstringAbsolute path to project root on the host.