DockerfileStage Methods
ClassMethods17 members
Represents a stage within a multi-stage Dockerfile.
Adds an ARG statement to define a build-time variable.
public class DockerfileStage{ public DockerfileStage Arg( string name) { // ... }}Parameters
namestringThe name of the build argument.Returns
DockerfileStageThe current stage. Adds an ARG statement to define a build-time variable with a default value.
public class DockerfileStage{ public DockerfileStage Arg( string name, string defaultValue) { // ... }}Parameters
namestringThe name of the build argument.defaultValuestringThe default value for the build argument.Returns
DockerfileStageThe current stage. Adds a CMD statement to set the default command.
public class DockerfileStage{ public DockerfileStage Cmd( string[] command) { // ... }}Parameters
commandstring[]The command to execute.Returns
DockerfileStageThe current stage. Adds a comment to the Dockerfile. Multi-line comments are supported.
public class DockerfileStage{ public DockerfileStage Comment( string comment) { // ... }}Parameters
commentstringThe comment text. Can be single-line or multi-line.Returns
DockerfileStageThe current stage.Remarks
When a multi-line comment is provided, each line will be prefixed with '#'. Empty lines in multi-line comments are preserved as comment lines.
Adds a COPY statement to copy files from the build context.
public class DockerfileStage{ public DockerfileStage Copy( string source, string destination) { // ... }}Parameters
sourcestringThe source path or pattern.destinationstringThe destination path.Returns
DockerfileStageThe current stage. Adds a COPY statement to copy files with ownership change.
public class DockerfileStage{ public DockerfileStage Copy( string source, string destination, string chown) { // ... }}Parameters
sourcestringThe source path.destinationstringThe destination path.chownstringThe ownership specification (e.g., "user:group").Returns
DockerfileStageThe current stage. Adds a COPY statement to copy files from another stage.
public class DockerfileStage{ public DockerfileStage CopyFrom( string from, string source, string destination) { // ... }}Parameters
fromstringThe source stage or image name.sourcestringThe source path in the stage.destinationstringThe destination path.Returns
DockerfileStageThe current stage.CopyFrom(string, string, string, string)Section titled CopyFrom(string, string, string, string)DockerfileStage Adds a COPY statement to copy files from another stage with ownership change.
public class DockerfileStage{ public DockerfileStage CopyFrom( string stage, string source, string destination, string chown) { // ... }}Parameters
stagestringThe source stage name.sourcestringThe source path in the stage.destinationstringThe destination path.chownstringThe ownership specification (e.g., "user:group").Returns
DockerfileStageThe current stage. Adds an empty line to the Dockerfile for better readability.
public class DockerfileStage{ public DockerfileStage EmptyLine() { // ... }}Returns
DockerfileStageThe current stage. Adds an ENTRYPOINT statement to set the container entrypoint.
public class DockerfileStage{ public DockerfileStage Entrypoint( string[] command) { // ... }}Parameters
commandstring[]The entrypoint command to execute.Returns
DockerfileStageThe current stage. Adds an ENV statement to set an environment variable.
public class DockerfileStage{ public DockerfileStage Env( string name, string value) { // ... }}Parameters
namestringThe environment variable name.valuestringThe environment variable value.Returns
DockerfileStageThe current stage. Adds an EXPOSE statement to expose a port.
public class DockerfileStage{ public DockerfileStage Expose( int port) { // ... }}Parameters
portintThe port number to expose.Returns
DockerfileStageThe current stage. Adds a RUN statement to execute a command.
public class DockerfileStage{ public DockerfileStage Run( string command) { // ... }}Parameters
commandstringThe command to execute.Returns
DockerfileStageThe current stage. Adds a RUN statement with mount options for BuildKit.
public class DockerfileStage{ public DockerfileStage RunWithMounts( string command, params string[] mounts) { // ... }}Parameters
commandstringThe command to execute.mountsstring[]The mount options (e.g., "type=cache,target=/root/.cache").Returns
DockerfileStageThe current stage. Adds a USER statement to set the user for subsequent commands.
public class DockerfileStage{ public DockerfileStage User( string user) { // ... }}Parameters
userstringThe user name or UID.Returns
DockerfileStageThe current stage. Adds a WORKDIR statement to set the working directory.
public class DockerfileStage{ public DockerfileStage WorkDir( string path) { // ... }}Parameters
pathstringThe working directory path.Returns
DockerfileStageThe current stage.WriteStatementAsync(StreamWriter, CancellationToken)Section titled WriteStatementAsync(StreamWriter, CancellationToken)overrideTask Writes the statement to the specified writer.
public class DockerfileStage{ public override Task WriteStatementAsync( StreamWriter writer, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
writerStreamWriterThe writer to write to.cancellationTokenCancellationTokenoptionalA cancellation token.Returns
TaskA task representing the asynchronous write operation.