# Image (/docs/go-sdk/image)

> For AI agents: the complete documentation index is at https://www.daytona.com/llms.txt.

## Images [#images]

```go
type Images struct {
	// contains filtered or unexported fields
}
```

Images manages reusable sandbox images. Obtain it with Client.Images.
Its methods are safe for concurrent use.

#### Images.Build [#imagesbuild]

```go
func (s *Images) Build(ctx context.Context, builder *ImageBuilder, opts *BuildImageOptions) (*Image, error)
```

Build submits a declarative builder and returns its initial observation,
without waiting for readiness. Use ImageFromDockerfile for Dockerfile text.
Invalid options and builder inputs return ErrBadRequest before submission.

#### Images.BuildAndWait [#imagesbuildandwait]

```go
func (s *Images) BuildAndWait(ctx context.Context, builder *ImageBuilder, opts *BuildImageWaitOptions) (*Image, error)
```

BuildAndWait builds an image and waits until ready, raising
ImageBuildFailedError with the image ID and recorded error on failure.
Its readiness timeout starts after Build, so context upload keeps its own
bounds. A subsequent sandbox create should use image.ID and the same region.

**Example**:

```go
ctx := context.Background()
client, err := daytona.New()
if err != nil {
	fmt.Println(err)
	return
}
defer func() {
	if closeErr := client.Close(); closeErr != nil {
		fmt.Println(closeErr)
	}
}()

// Build once, then use the image ID for many sandboxes.
builder := daytona.NewImageBuilder("python:3.12-slim").PipInstall("pandas")
image, err := client.Images().BuildAndWait(ctx, builder, &daytona.BuildImageWaitOptions{
	BuildImageOptions: daytona.BuildImageOptions{Name: "python312-pandas"},
	Timeout:           10 * time.Minute,
})
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(image.ID)

// With the sandbox lifecycle API:
// sandbox, err := client.Create(ctx, image.ID, nil)
// Use the sandbox, then sandbox.Delete(ctx, nil) before deleting the image.
// Keep the same Region on build and create when selecting one explicitly.
if err = client.Images().Delete(ctx, image.ID); err != nil {
	fmt.Println(err)
}
```

#### Images.BuildFromContext [#imagesbuildfromcontext]

```go
func (s *Images) BuildFromContext(
	ctx context.Context, contextPath string, opts *BuildFromContextOptions,
) (*Image, error)
```

BuildFromContext archives a local directory or snapshots an existing tar file,
then uploads it and submits a build. Caller-owned tar files are never removed;
edits after preparation do not change the uploaded bytes.
It honors Dockerfile-specific ignore rules, otherwise .dockerignore, and
refuses contexts over 1 GiB. All sizes upload directly to storage, using the
server's multipart layout for large archives, without a 64 MiB API-body cap.
The result is an initial observation; wait using Get or BuildAndWait.

**Example**:

```go
ctx := context.Background()
client, err := daytona.New()
if err != nil {
	fmt.Println(err)
	return
}
defer func() {
	if closeErr := client.Close(); closeErr != nil {
		fmt.Println(closeErr)
	}
}()

image, err := client.Images().BuildFromContext(ctx, "./app", &daytona.BuildFromContextOptions{
	Dockerfile: "docker/Dockerfile",
})
if err != nil {
	fmt.Println(err)
	return
}
image, err = client.Images().Get(ctx, image.ID, &daytona.GetArtifactOptions{
	Wait: true, Timeout: 10 * time.Minute,
})
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(image.Status)
```

#### Images.BuildFromContextReader [#imagesbuildfromcontextreader]

```go
func (s *Images) BuildFromContextReader(
	ctx context.Context, r io.ReaderAt, size int64, opts *BuildFromContextOptions,
) (*Image, error)
```

BuildFromContextReader snapshots size archive bytes from r starting at offset
zero, then uploads them and submits a build without waiting for readiness.
Size must be positive and at most 1 GiB; invalid sizes, nil readers, short reads
and unsafe Dockerfile paths return ErrBadRequest before any network request.
Options and multipart upload behavior are the same as BuildFromContext.
The caller retains ownership of r and must keep its bytes stable during the
call. Reads must return promptly: context cancellation is checked between
reads but cannot interrupt a blocking ReaderAt. The SDK never closes r.

**Example**:

```go
client, err := daytona.New()
if err != nil {
	fmt.Println(err)
	return
}
defer func() {
	if closeErr := client.Close(); closeErr != nil {
		fmt.Println(closeErr)
	}
}()

archive, err := os.ReadFile("context.tar")
if err != nil {
	fmt.Println(err)
	return
}
// The same call accepts archive bytes assembled in memory by your program.
image, err := client.Images().BuildFromContextReader(
	context.Background(), bytes.NewReader(archive), int64(len(archive)), nil,
)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(image.ID)
```

#### Images.Delete [#imagesdelete]

```go
func (s *Images) Delete(ctx context.Context, id string) error
```

Delete deletes an image by ID or name. A missing image returns ErrNotFound.
While a sandbox still uses the image it returns ErrConflict; this includes
the few seconds after Sandbox.Delete returned, until the platform released
the image, so retry a conflict after a moment.

#### Images.FollowBuildLogs [#imagesfollowbuildlogs]

```go
func (s *Images) FollowBuildLogs(ctx context.Context, imageID string,
	opts *FollowBuildLogsOptions,
) iter.Seq2[BuildLogEvent, error]
```

FollowBuildLogs observes an image build lazily, with the same checkpoint,
retry and cancellation semantics as Sandbox.FollowBuildLogs.

**Example**:

```go
client, err := daytona.New()
if err != nil {
	log.Print(err)
	return
}
defer func() {
	if closeErr := client.Close(); closeErr != nil {
		log.Print(closeErr)
	}
}()
for event, followErr := range client.Images().FollowBuildLogs(context.Background(), "image-id", nil) {
	if followErr != nil {
		log.Print(followErr)
		return
	}
	switch value := event.(type) {
	case daytona.BuildLogChunkEvent:
		if _, writeErr := os.Stdout.Write(value.Data); writeErr != nil {
			log.Print(writeErr)
			return
		}
		// Persist value.Cursor together with the output to resume safely.
	case daytona.BuildLogDoneEvent:
		fmt.Printf("status=%s complete=%t\n", value.Result.Status, value.Result.OutputComplete)
	}
}
```

#### Images.Get [#imagesget]

```go
func (s *Images) Get(ctx context.Context, id string, opts *GetArtifactOptions) (*Image, error)
```

Get fetches an image by ID or name. The reserved name "search" is refused;
use its ID instead. With a wait, failed/error observations are returned,
not raised; Pull and BuildAndWait raise ImageBuildFailedError instead.

#### Images.List [#imageslist]

```go
func (s *Images) List(ctx context.Context, opts *ListImagesOptions) (*Page[Image], error)
```

List returns one page of image values, preferring eventually consistent search
and falling back only on 404 or SEARCH_NOT_CONFIGURED. Get reads new images immediately.

#### Images.ListAll [#imageslistall]

```go
func (s *Images) ListAll(ctx context.Context, opts *ListImagesOptions) iter.Seq2[Image, error]
```

ListAll lazily visits all image pages, stopping on cancellation, a repeated
cursor, or when the consumer breaks. Options are copied at the call.

#### Images.Promote [#imagespromote]

```go
func (s *Images) Promote(ctx context.Context, id, name string) (*Image, error)
```

Promote names an anonymous image, making it permanent. It does not rename
named images. Name conflicts and reserved prefixes are reported by the API.
A blank or invalid UTF-8 name returns ErrBadRequest before any request.

#### Images.Pull [#imagespull]

```go
func (s *Images) Pull(ctx context.Context, ref string, opts *PullImageOptions) (*Image, error)
```

Pull imports a registry reference and waits for readiness by default.
Wait=false returns the initial observation. Failed imports raise
ImageBuildFailedError; an exhausted total budget raises ErrRequestTimeout.

## BuildFromContextOptions [#buildfromcontextoptions]

```go
type BuildFromContextOptions struct {
	// BuildImageOptions controls naming, retention and placement.
	BuildImageOptions
	// Dockerfile is the relative path inside the context; empty uses Dockerfile.
	Dockerfile string
	// Timeout bounds only the build submission after upload. Zero uses the
	// client's request timeout; NoTimeout disables it. Uploads have their own
	// no-progress bound from the client's request timeout, not this total bound.
	Timeout time.Duration
}
```

BuildFromContextOptions selects a Dockerfile in a path or reader build context.

## BuildImageOptions [#buildimageoptions]

```go
type BuildImageOptions struct {
	// Name makes an image permanent; empty creates an anonymous image.
	Name string
	// IdleExpiry is the anonymous image's idle retention. Zero omits it,
	// WaitForever requests the server maximum; otherwise use positive whole seconds.
	// Named images cannot combine Name and IdleExpiry.
	IdleExpiry time.Duration
	// Region selects placement. Empty, blank or "local" uses the default.
	Region string
	// CPUArch selects amd64 or arm64; empty uses the server default.
	CPUArch CPUArch
}
```

BuildImageOptions controls image naming, retention and placement.

## BuildImageWaitOptions [#buildimagewaitoptions]

```go
type BuildImageWaitOptions struct {
	// BuildImageOptions controls naming, retention and placement.
	BuildImageOptions
	// Timeout starts after submission and its initial lookup, excluding local
	// archiving and upload. Zero or WaitForever has no SDK readiness deadline.
	Timeout time.Duration
}
```

BuildImageWaitOptions controls a build followed by readiness.

## BuildLogChunkEvent [#buildlogchunkevent]

```go
type BuildLogChunkEvent struct {
	// Data is the decoded log chunk, at most 64 KiB; it need not be UTF-8.
	Data []byte
	// StartOffset is the inclusive byte offset.
	StartOffset uint64
	// NextOffset is the exclusive byte offset.
	NextOffset uint64
	// Cursor resumes immediately after these bytes.
	Cursor string
}
```

BuildLogChunkEvent contains caller-owned bytes and their checkpoint.
Persist Data and Cursor together before requesting the next event.

## BuildLogDoneEvent [#buildlogdoneevent]

```go
type BuildLogDoneEvent struct {
	// Result describes completion and output completeness.
	Result BuildLogFollowResult
}
```

BuildLogDoneEvent is the last event of a successfully completed observation.

## BuildLogDoneReason [#buildlogdonereason]

```go
type BuildLogDoneReason string
```

BuildLogDoneReason explains why observation completed.

```go
const (
	// BuildLogDoneReasonUnknown preserves a future reason in RawReason.
	BuildLogDoneReasonUnknown BuildLogDoneReason = "unknown"
	// BuildLogDoneReasonTerminal means the build reached a terminal state.
	BuildLogDoneReasonTerminal BuildLogDoneReason = "terminal"
	// BuildLogDoneReasonDeadline means the server observation deadline passed.
	BuildLogDoneReasonDeadline BuildLogDoneReason = "deadline"
	// BuildLogDoneReasonNotApplicable means this resource has no build output.
	BuildLogDoneReasonNotApplicable BuildLogDoneReason = "not_applicable"
	// BuildLogDoneReasonResourceDeleted means the resource was deleted.
	BuildLogDoneReasonResourceDeleted BuildLogDoneReason = "resource_deleted"
)
```

## BuildLogErrorEvent [#buildlogerrorevent]

```go
type BuildLogErrorEvent struct {
	// Error is the server explanation.
	Error string
	// Code is the open server error code.
	Code string
	// Retryable determines whether observation reconnects.
	Retryable bool
	// TraceID is the optional server trace identifier.
	TraceID string
}
```

BuildLogErrorEvent reports a server stream error before retry or interruption.

## BuildLogEvent [#buildlogevent]

```go
type BuildLogEvent interface {
	// contains filtered or unexported methods
}
```

BuildLogEvent is one of BuildLogStateEvent, BuildLogChunkEvent,
BuildLogGapEvent, BuildLogUnavailableEvent, BuildLogSourceChangedEvent,
BuildLogDoneEvent or BuildLogErrorEvent. Use a type switch to inspect it.

## BuildLogFollowResult [#buildlogfollowresult]

```go
type BuildLogFollowResult struct {
	// Status is the server's build status.
	Status string
	// Reason is the normalized completion reason.
	Reason BuildLogDoneReason
	// RawReason is the server's reason verbatim.
	RawReason string
	// Cursor is the final checkpoint, or empty when none was supplied.
	Cursor string
	// OutputComplete is false if any gap was observed.
	OutputComplete bool
}
```

BuildLogFollowResult describes explicit completion, including failed builds.
Status is an open server vocabulary; completion does not imply build success.

## BuildLogGapEvent [#buildloggapevent]

```go
type BuildLogGapEvent struct {
	// Reason is the normalized gap reason.
	Reason BuildLogGapReason
	// RawReason is the server's reason verbatim.
	RawReason string
	// RequestedOffset is the byte offset requested.
	RequestedOffset uint64
	// FirstAvailableOffset is the earliest retained byte offset.
	FirstAvailableOffset uint64
	// DroppedBytes is the number of missing bytes.
	DroppedBytes uint64
	// Cursor resumes at FirstAvailableOffset.
	Cursor string
}
```

BuildLogGapEvent reports discarded bytes and advances the checkpoint.

## BuildLogGapReason [#buildloggapreason]

```go
type BuildLogGapReason string
```

BuildLogGapReason explains missing output.

```go
const (
	// BuildLogGapReasonUnknown preserves a future reason in RawReason.
	BuildLogGapReasonUnknown BuildLogGapReason = "unknown"
	// BuildLogGapReasonTruncated means earlier output was discarded.
	BuildLogGapReasonTruncated BuildLogGapReason = "truncated"
)
```

## BuildLogSourceChangedEvent [#buildlogsourcechangedevent]

```go
type BuildLogSourceChangedEvent struct {
	// Reason is the server explanation.
	Reason string
}
```

BuildLogSourceChangedEvent reports replacement of the observed log source.
The next iterator value is a BuildLogInterruptedError; no restart occurs.

## BuildLogStateEvent [#buildlogstateevent]

```go
type BuildLogStateEvent struct {
	// Status is the open server build status.
	Status string
	// Error is the optional server failure detail.
	Error string
	// DeadlineAt is server execution metadata, not an observation timeout.
	// Zero means absent.
	DeadlineAt time.Time
}
```

BuildLogStateEvent reports build state without advancing the checkpoint.

## BuildLogUnavailableEvent [#buildlogunavailableevent]

```go
type BuildLogUnavailableEvent struct {
	// Reason is the server explanation.
	Reason string
}
```

BuildLogUnavailableEvent reports temporarily unavailable output.

## BuildLogsSnapshot [#buildlogssnapshot]

```go
type BuildLogsSnapshot struct {
	// Text is the server's retained build-log snapshot.
	Text string
}
```

BuildLogsSnapshot contains retained output and server state as plain text.
Output may be incomplete while building; truncation is indicated in Text.

## CPUArch [#cpuarch]

```go
type CPUArch string
```

CPUArch is the CPU architecture of a sandbox or image.

**Example**:

```go
// The same architecture configures both sandbox creation and image builds.
create := daytona.CreateOptions{CPUArch: daytona.CPUArchARM64}
build := daytona.BuildImageOptions{CPUArch: create.CPUArch}
fmt.Println(create.CPUArch, build.CPUArch)
// Output: arm64 arm64
```

Output:

```text
arm64 arm64
```

```go
const (
	// CPUArchAMD64 selects x86-64.
	CPUArchAMD64 CPUArch = "amd64"
	// CPUArchARM64 selects ARM64.
	CPUArchARM64 CPUArch = "arm64"
)
```

## CaptureImageOptions [#captureimageoptions]

```go
type CaptureImageOptions struct {
	// Name makes the capture permanent; empty creates an anonymous image.
	Name string
	// IdleExpiry is positive whole seconds, WaitForever for the server maximum,
	// or zero to use the server default. It cannot be combined with Name.
	IdleExpiry time.Duration
}
```

CaptureImageOptions names a filesystem capture or configures idle retention.

## DockerfileImageSource [#dockerfileimagesource]

```go
type DockerfileImageSource struct {
	// Dockerfile is the Dockerfile path within the build context.
	Dockerfile string
}
```

DockerfileImageSource describes a Dockerfile build.

#### DockerfileImageSource.Type [#dockerfileimagesourcetype]

```go
func (DockerfileImageSource) Type() ImageSourceType
```

Type returns ImageSourceTypeDockerfile.

## FollowBuildLogsOptions [#followbuildlogsoptions]

```go
type FollowBuildLogsOptions struct {
	// Cursor resumes after a delivered checkpoint; empty starts at byte zero.
	Cursor string
	// Timeout bounds discovery, reconnects and observation as a whole. Zero,
	// NoTimeout, WaitForever or a value above 2,147,483.647 seconds adds no
	// overall deadline. Each discovery request also keeps the client request
	// timeout (WithRequestTimeout), as in the other SDKs. The context still
	// bounds every operation.
	Timeout time.Duration
}
```

FollowBuildLogsOptions configures resumable build observation.

## GetArtifactOptions [#getartifactoptions]

```go
type GetArtifactOptions struct {
	// Wait requests readiness. False performs an ordinary read.
	Wait bool
	// Timeout is the total readiness budget. Zero performs one server-default
	// hold, returning its observation. Positive budgets repeat holds until ready,
	// failed or error; WaitForever repeats without an SDK deadline.
	// Values above 2,147,483.647 seconds also mean forever.
	// Without Wait this field is validated but unused.
	Timeout time.Duration
}
```

GetArtifactOptions configures an image or snapshot lookup.

## Image [#image]

```go
type Image struct {
	// ID is the stable image identifier.
	ID string
	// Name is empty for an anonymous image.
	Name string
	// Anonymous reports whether the image has no permanent name.
	Anonymous bool
	// AvailableIn lists regions where the image is available.
	AvailableIn []string
	// Bytes is the stored size, or nil when unreported.
	Bytes *int64
	// Class is the normalized operating-system class.
	Class ImageClass
	// RawClass preserves the server class.
	RawClass string
	// CreatedAt is the creation time.
	CreatedAt time.Time
	// UpdatedAt is the last update time.
	UpdatedAt time.Time
	// Error is the recorded build failure.
	Error string
	// ExpiresAt is zero when expiry is unreported.
	ExpiresAt time.Time
	// LayerCount is nil when unreported.
	LayerCount *int64
	// Origin identifies how the image was created.
	Origin ImageOrigin
	// RawOrigin preserves the server origin.
	RawOrigin string
	// Region is the image's home region.
	Region string
	// Retention identifies its retention policy.
	Retention ImageRetention
	// RawRetention preserves the server retention policy.
	RawRetention string
	// Source describes its input, or nil when unreported.
	Source ImageSource
	// Status is the normalized build status.
	Status ImageStatus
	// RawStatus preserves the server status.
	RawStatus string
	// FormatVersion is the image format version.
	FormatVersion int64
	// FormatOutdated reports whether rebuilding is required.
	FormatOutdated bool
	// Platform reports whether this is a platform-provided image.
	Platform bool
	// Default reports whether this is the platform default.
	Default bool
	// Deprecated reports whether the image is deprecated.
	Deprecated bool
	// DiskGiB is the disk size in GiB, or nil when unreported.
	DiskGiB *float64
}
```

Image is a caller-owned observation of a reusable sandbox image.

## ImageBuilder [#imagebuilder]

```go
type ImageBuilder struct {
	// contains filtered or unexported fields
}
```

ImageBuilder is an immutable image recipe. Chaining methods return new
builders, preserving earlier recipes and copying caller-owned inputs.
Invalid input is retained and returned as ErrBadRequest by Dockerfile or Build.
A zero-value builder has no base and is invalid.

**Example**:

```go
builder := daytona.NewImageBuilder("python:3.13-slim").
	PipInstall("requests>=2").
	Env("APP_MODE", "production").
	Workdir("/app").
	Cmd("python", "app.py")
dockerfile, err := builder.Dockerfile()
if err != nil {
	log.Fatal(err)
}
fmt.Print(dockerfile)
// Output:
// FROM python:3.13-slim
// RUN python -m pip install 'requests>=2'
// ENV APP_MODE="production"
// WORKDIR /app
// CMD ["python", "app.py"]
```

Output:

```text
FROM python:3.13-slim
RUN python -m pip install 'requests>=2'
ENV APP_MODE="production"
WORKDIR /app
CMD ["python", "app.py"]
```

#### DebianSlim [#debianslim]

```go
func DebianSlim(version string) *ImageBuilder
```

DebianSlim starts from python:\<version>-slim-bookworm with compiler packages
and an upgraded pip. Empty version defaults to "3.13"; supported series are
"3.10" through "3.14". Unsupported versions fail compilation with ErrBadRequest.

#### ImageFromDockerfile [#imagefromdockerfile]

```go
func ImageFromDockerfile(text string) *ImageBuilder
```

ImageFromDockerfile starts with Dockerfile text, rather than a filesystem path.
Additional steps cannot follow an unfinished line continuation. Compilation
reports invalid UTF-8 or blank text as ErrBadRequest.

#### NewImageBuilder [#newimagebuilder]

```go
func NewImageBuilder(base string) *ImageBuilder
```

NewImageBuilder starts with a registry reference, such as "python:3.13-slim".
A bare registry builder is imported without a Dockerfile build. Invalid or
multiline references produce ErrBadRequest when compiled or built.

#### ImageBuilder.AddLocalDir [#imagebuilderaddlocaldir]

```go
func (b *ImageBuilder) AddLocalDir(localPath, remotePath string) *ImageBuilder
```

AddLocalDir adds a directory's contents, honoring its root .dockerignore and
omitting that ignore file. Build rejects links escaping the directory and
unsupported file types. Local paths follow AddLocalFile's rules.

**Example**:

```go
builder := daytona.DebianSlim("").
	AddLocalDir("./src", "/app").
	PipInstallFromRequirements("./requirements.txt").
	Workdir("/app").
	Cmd("python", "main.py")
dockerfile, err := builder.Dockerfile()
if err != nil {
	log.Fatal(err)
}
fmt.Print(dockerfile)
```

#### ImageBuilder.AddLocalFile [#imagebuilderaddlocalfile]

```go
func (b *ImageBuilder) AddLocalFile(localPath, remotePath string) *ImageBuilder
```

AddLocalFile adds a COPY of a local regular file. Metadata is captured now,
while contents are read at build time. A trailing '/' on remotePath appends
the original filename. Only '~' and '~/' expand to the current home directory.
Invalid paths are reported by Dockerfile or Build as ErrBadRequest.

#### ImageBuilder.Cmd [#imagebuildercmd]

```go
func (b *ImageBuilder) Cmd(args ...string) *ImageBuilder
```

Cmd adds an exec-form CMD, preserving argument whitespace and Unicode.
At least one argument is required, and each must be nonblank valid UTF-8.
Invalid input fails compilation with ErrBadRequest.

#### ImageBuilder.Dockerfile [#imagebuilderdockerfile]

```go
func (b *ImageBuilder) Dockerfile() (string, error)
```

Dockerfile compiles the recipe to Dockerfile text with one trailing newline.
It reports retained validation errors as ErrBadRequest without reading local
file contents or making a network request.

#### ImageBuilder.Entrypoint [#imagebuilderentrypoint]

```go
func (b *ImageBuilder) Entrypoint(args ...string) *ImageBuilder
```

Entrypoint adds an exec-form ENTRYPOINT with the same validation as Cmd.

#### ImageBuilder.Env [#imagebuilderenv]

```go
func (b *ImageBuilder) Env(name, value string) *ImageBuilder
```

Env adds a literal environment variable, escaping dollars, quotes and
backslashes. Names are trimmed; values are preserved. Blank names/values,
controls, whitespace or '=' in names, and non-default Dockerfile escape
directives fail compilation with ErrBadRequest. Errors never echo values.

#### ImageBuilder.EnvVars [#imagebuilderenvvars]

```go
func (b *ImageBuilder) EnvVars(values map[string]string) *ImageBuilder
```

EnvVars adds literal variables in sorted key order for deterministic output.
The map is snapshotted. Empty maps add nothing. Keys colliding after trimming
and values invalid under Env's rules fail compilation with ErrBadRequest.

#### ImageBuilder.PipInstall [#imagebuilderpipinstall]

```go
func (b *ImageBuilder) PipInstall(packages ...string) *ImageBuilder
```

PipInstall adds python -m pip install with POSIX-shell-quoted packages.
At least one nonblank package is required; pip options can be written with
RunCommands. Invalid input fails compilation with ErrBadRequest.

#### ImageBuilder.PipInstallFromRequirements [#imagebuilderpipinstallfromrequirements]

```go
func (b *ImageBuilder) PipInstallFromRequirements(localPath string) *ImageBuilder
```

PipInstallFromRequirements copies a local requirements file to
/.requirements.txt and installs it with python -m pip. Put additional pip
options in RunCommands. Path failures follow AddLocalFile's rules.

#### ImageBuilder.RunCommands [#imagebuilderruncommands]

```go
func (b *ImageBuilder) RunCommands(commands ...string) *ImageBuilder
```

RunCommands adds one RUN instruction per command. Commands must be nonblank
single lines; invalid commands fail compilation with ErrBadRequest.

#### ImageBuilder.User [#imagebuilderuser]

```go
func (b *ImageBuilder) User(name string) *ImageBuilder
```

User adds USER. Blank, multiline, or continuation-ending names fail
compilation with ErrBadRequest.

#### ImageBuilder.Workdir [#imagebuilderworkdir]

```go
func (b *ImageBuilder) Workdir(path string) *ImageBuilder
```

Workdir adds WORKDIR. Dockerfile variable substitution is preserved. Blank,
multiline, or continuation-ending paths fail compilation with ErrBadRequest.

## ImageClass [#imageclass]

```go
type ImageClass string
```

ImageClass identifies an image's operating-system class.

```go
const (
	// ImageClassUnknown identifies a future class.
	ImageClassUnknown ImageClass = "unknown"
	// ImageClassLinux identifies Linux images.
	ImageClassLinux ImageClass = "linux"
	// ImageClassMacOS identifies macOS images.
	ImageClassMacOS ImageClass = "macos"
	// ImageClassWindows identifies Windows images.
	ImageClassWindows ImageClass = "windows"
)
```

## ImageOrigin [#imageorigin]

```go
type ImageOrigin string
```

ImageOrigin identifies how an image was created.

```go
const (
	// ImageOriginUnknown identifies a future origin.
	ImageOriginUnknown ImageOrigin = "unknown"
	// ImageOriginRegistry identifies a registry import.
	ImageOriginRegistry ImageOrigin = "registry"
	// ImageOriginDockerfile identifies a Dockerfile build.
	ImageOriginDockerfile ImageOrigin = "dockerfile"
	// ImageOriginCapture identifies a sandbox filesystem capture.
	ImageOriginCapture ImageOrigin = "capture"
	// ImageOriginWindows identifies a Windows image.
	ImageOriginWindows ImageOrigin = "windows"
	// ImageOriginMacOS identifies a macOS image.
	ImageOriginMacOS ImageOrigin = "macos"
)
```

## ImagePlatformFilter [#imageplatformfilter]

```go
type ImagePlatformFilter string
```

ImagePlatformFilter selects platform-provided images. Only the defined
constants are accepted; empty omits the filter.

```go
const (
	// ImagePlatformOnly selects platform images.
	ImagePlatformOnly ImagePlatformFilter = "true"
	// ImagePlatformExclude selects project images.
	ImagePlatformExclude ImagePlatformFilter = "false"
	// ImagePlatformAny selects both kinds.
	ImagePlatformAny ImagePlatformFilter = "any"
)
```

## ImageRetention [#imageretention]

```go
type ImageRetention string
```

ImageRetention identifies an image's retention policy.

```go
const (
	// ImageRetentionUnknown identifies a future retention policy.
	ImageRetentionUnknown ImageRetention = "unknown"
	// ImageRetentionPermanent retains an image until deleted.
	ImageRetentionPermanent ImageRetention = "permanent"
	// ImageRetentionIdle removes an image after its idle window.
	ImageRetentionIdle ImageRetention = "idle"
)
```

## ImageSource [#imagesource]

```go
type ImageSource interface {
	// Type identifies the source variant without inspecting concrete types.
	Type() ImageSourceType
	// contains filtered or unexported methods
}
```

ImageSource is the closed set of source descriptions returned by the SDK.
A future source kind is represented by UnknownImageSource.

## ImageSourceType [#imagesourcetype]

```go
type ImageSourceType string
```

ImageSourceType is a normalized source discriminator.

```go
const (
	// ImageSourceTypeUnknown identifies a future kind; see UnknownImageSource.RawType.
	ImageSourceTypeUnknown ImageSourceType = "unknown"
	// ImageSourceTypeRegistry identifies an imported registry reference.
	ImageSourceTypeRegistry ImageSourceType = "registry"
	// ImageSourceTypeDockerfile identifies a Dockerfile build.
	ImageSourceTypeDockerfile ImageSourceType = "dockerfile"
	// ImageSourceTypeNamed identifies a named source.
	ImageSourceTypeNamed ImageSourceType = "named"
	// ImageSourceTypeManifest identifies a manifest source.
	ImageSourceTypeManifest ImageSourceType = "manifest"
)
```

## ImageStatus [#imagestatus]

```go
type ImageStatus string
```

ImageStatus is an image's build status; future values map to ImageStatusUnknown.

```go
const (
	// ImageStatusUnknown identifies a future server status.
	ImageStatusUnknown ImageStatus = "unknown"
	// ImageStatusPending means the build is queued.
	ImageStatusPending ImageStatus = "pending"
	// ImageStatusBuilding means the build is running.
	ImageStatusBuilding ImageStatus = "building"
	// ImageStatusReady means the image can create sandboxes.
	ImageStatusReady ImageStatus = "ready"
	// ImageStatusFailed means the build failed.
	ImageStatusFailed ImageStatus = "failed"
	// ImageStatusError is the server's alternative failure status.
	ImageStatusError ImageStatus = "error"
)
```

## ListImagesOptions [#listimagesoptions]

```go
type ListImagesOptions struct {
	// Cursor is the opaque continuation cursor.
	Cursor string
	// Limit is 1–200; zero uses the server default.
	Limit int
	// Name filters by image name.
	Name string
	// Anonymous selects unnamed images; nil uses the server default (false).
	Anonymous *bool
	// SandboxID filters captures of this sandbox.
	SandboxID string
	// Platform selects platform or project images; unknown values return ErrBadRequest.
	Platform ImagePlatformFilter
}
```

ListImagesOptions filters one page of images. Zero values use server defaults.

## ManifestImageSource [#manifestimagesource]

```go
type ManifestImageSource struct {
	// Name is the manifest name.
	Name string
}
```

ManifestImageSource describes a manifest source.

#### ManifestImageSource.Type [#manifestimagesourcetype]

```go
func (ManifestImageSource) Type() ImageSourceType
```

Type returns ImageSourceTypeManifest.

## NamedImageSource [#namedimagesource]

```go
type NamedImageSource struct {
	// Name is the source name.
	Name string
}
```

NamedImageSource describes a named image source.

#### NamedImageSource.Type [#namedimagesourcetype]

```go
func (NamedImageSource) Type() ImageSourceType
```

Type returns ImageSourceTypeNamed.

## PullImageOptions [#pullimageoptions]

```go
type PullImageOptions struct {
	// BuildImageOptions controls naming, retention and placement.
	BuildImageOptions
	// Wait defaults to true when nil; false returns after submission and lookup.
	Wait *bool
	// Timeout bounds submission, lookup and readiness together. Zero or
	// WaitForever is unbounded; caller cancellation always applies.
	Timeout time.Duration
}
```

PullImageOptions controls a registry import.

## RegistryImageSource [#registryimagesource]

```go
type RegistryImageSource struct {
	// Ref is the registry reference.
	Ref string
}
```

RegistryImageSource describes an imported registry reference.

#### RegistryImageSource.Type [#registryimagesourcetype]

```go
func (RegistryImageSource) Type() ImageSourceType
```

Type returns ImageSourceTypeRegistry.

## UnknownImageSource [#unknownimagesource]

```go
type UnknownImageSource struct {
	// RawType is the server's source discriminator.
	RawType string
}
```

UnknownImageSource preserves a source kind added by a newer API.

#### UnknownImageSource.Type [#unknownimagesourcetype]

```go
func (UnknownImageSource) Type() ImageSourceType
```

Type returns ImageSourceTypeUnknown; RawType preserves the server kind.
