# DockerfileBuilder

- Kind: `class`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.3.0`
- Namespace: `Aspire.Hosting.ApplicationModel.Docker`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/Docker/DockerfileBuilder.cs)

Builder for creating Dockerfiles programmatically.

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel.Docker;

public class DockerfileBuilder
{
    // ...
}
```

## ATS metadata

### ATS export

- Type ID: `Aspire.Hosting/DockerfileBuilder`

## Constructors

- [DockerfileBuilder](/reference/api/csharp/aspire.hosting/dockerfilebuilder/constructors.md#constructor) -- Initializes a new instance of the [DockerfileBuilder](/reference/api/csharp/aspire.hosting/dockerfilebuilder.md) class.

## Properties

- [Stages](/reference/api/csharp/aspire.hosting/dockerfilebuilder/properties.md#stages) : [IReadOnlyList<DockerfileStage>](/reference/api/csharp/aspire.hosting/dockerfilestage.md) `get` -- Gets the stages in this Dockerfile.

## Methods

- [Arg(string)](/reference/api/csharp/aspire.hosting/dockerfilebuilder/methods.md#arg-string) : [DockerfileBuilder](/reference/api/csharp/aspire.hosting/dockerfilebuilder.md) `experimental` -- Adds a global ARG statement to define a build-time variable before any stages.
- [Arg(string, string)](/reference/api/csharp/aspire.hosting/dockerfilebuilder/methods.md#arg-string-string) : [DockerfileBuilder](/reference/api/csharp/aspire.hosting/dockerfilebuilder.md) `experimental` -- Adds a global ARG statement to define a build-time variable with a default value before any stages.
- [From(string, string)](/reference/api/csharp/aspire.hosting/dockerfilebuilder/methods.md#from-string-string) : [DockerfileStage](/reference/api/csharp/aspire.hosting/dockerfilestage.md) `experimental` -- Adds a FROM statement to start a new named stage.
- [From(string)](/reference/api/csharp/aspire.hosting/dockerfilebuilder/methods.md#from-string) : [DockerfileStage](/reference/api/csharp/aspire.hosting/dockerfilestage.md) `experimental` -- Adds a FROM statement to start a new stage.
- [WriteAsync(StreamWriter, CancellationToken)](/reference/api/csharp/aspire.hosting/dockerfilebuilder/methods.md#writeasync-streamwriter-cancellationtoken) : `Task` -- Writes the Dockerfile content to the specified `IO.StreamWriter`.
