# WithContainerImage

- Module: [Aspire.Hosting.Radius](/reference/api/go/aspire.hosting.radius.md)
- Version: `17.0.0-preview.1.26565.2`
- Kind: `method`
- Defined on: `ProjectResource`
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Associates a pre-built container image reference with a project resource so the Aspire.Hosting.Radius publisher can emit a valid Radius container manifest for it.

## Remarks

The Radius publisher does not yet build or push images for `ProjectResource`
(tracked at https://github.com/microsoft/aspire/issues/16844). Until that lands,
callers must build and push the image themselves (for example with
`dotnet publish /t:PublishContainer`) and then call this method to attach
the resulting registry reference. Without it, `aspire publish` against a Radius
environment fails with a clear remediation message -- and `aspire deploy` against
Radius would otherwise land pods that hit `ImagePullBackOff` against the
publisher's `<name>:latest` fallback.
The reference is stored as a `ContainerImageAnnotation`, which is also
what container resources use, so the publisher's existing
`Registry`/`Image`/`Tag` assembly path applies uniformly.
The attached image is treated as a final artifact and is not modified by Aspire.
Include any files required by `PublishWithContainerFiles` when building the image
instead of combining that method with `WithContainerImage`.

## Definition

```go
func (ProjectResource) WithContainerImage(image string) ProjectResource
```

## Parameters

- `image` (`string`) -- A fully-qualified image reference in `[registry/]image[:tag]` form (for example `localhost:5001/apiservice:latest`). When the tag is omitted `latest` is used.

## Returns

`ProjectResource` -- The same `IResourceBuilder` for chaining.

Returns a handle; failures surface later via `Err()`.

## Applies to

- `CSharpAppResource`
- `ProjectResource`
