# RepositoryImage

An image hosted in a public or private repository.

For images hosted in Amazon ECR, see
[EcrImage](https://docs.aws.amazon.com/AmazonECR/latest/userguide/images.html).

Extends: [ContainerImage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.ContainerImage.html) › RepositoryImage
Obtainable from: [ContainerImage.fromRegistry](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.ContainerImage.html#fromregistry)

- Source: [`aws-ecs/lib/images/repository.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ecs/lib/images/repository.ts#L29)

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ecr_assets as ecr_assets } from 'aws-cdk-lib';
import { aws_ecs as ecs } from 'aws-cdk-lib';

declare const dockerImageAsset: ecr_assets.DockerImageAsset;
const repositoryImage = ecs.RepositoryImage.fromDockerImageAsset(dockerImageAsset);
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ecr_assets as ecr_assets
from aws_cdk import aws_ecs as ecs

# docker_image_asset: ecr_assets.DockerImageAsset

repository_image = ecs.RepositoryImage.from_docker_image_asset(docker_image_asset)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ecr.assets.*;
import software.amazon.awscdk.services.ecs.*;

DockerImageAsset dockerImageAsset;

ContainerImage repositoryImage = RepositoryImage.fromDockerImageAsset(dockerImageAsset);
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Ecr.Assets;
using Amazon.CDK.AWS.ECS;

DockerImageAsset dockerImageAsset;

var repositoryImage = RepositoryImage.FromDockerImageAsset(dockerImageAsset);
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var dockerImageAsset DockerImageAsset

repositoryImage := awscdk.Aws_ecs.RepositoryImage_FromDockerImageAsset(dockerImageAsset)
```

## Initializer

TypeScript:

```ts
new RepositoryImage(imageName: string, props?: RepositoryImageProps)
```

Python:

```python
RepositoryImage(image_name: str, props: typing.Optional[RepositoryImageProps] = None)
```

Java:

```java
new RepositoryImage(String imageName, RepositoryImageProps props)
```

C# / .NET:

```csharp
new RepositoryImage(string imageName, RepositoryImageProps? props = null)
```

Golang:

```go
NewRepositoryImage(ImageName *string, Props RepositoryImageProps)
```

## Methods

- `bind(scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfig` — Called when the image is used by a ContainerDefinition.

- `fromAsset(directory: string, props?: AssetImageProps): AssetImage` (static) — Reference an image that's constructed directly from sources on disk.

  If you already have a `DockerImageAsset` instance, you can use the
  `ContainerImage.fromDockerImageAsset` method instead.

  **Parameters**

  - `directory` — The directory containing the Dockerfile.

- `fromDockerImageAsset(asset: DockerImageAsset): ContainerImage` (static) — Use an existing `DockerImageAsset` for this container image.

  **Parameters**

  - `asset` — The `DockerImageAsset` to use for this container definition.

- `fromEcrRepository(repository: IRepository, tag?: string): EcrImage` (static) — Reference an image in an ECR repository.

  **Parameters**

  - `tag` — If you don't specify this parameter, `latest` is used as default.

- `fromRegistry(name: string, props?: RepositoryImageProps): RepositoryImage // chainable` (static) — Reference an image on DockerHub or another online registry.

- `fromTarball(tarballFile: string): ContainerImage` (static) — Use an existing tarball for this container image.

  Use this method if the container image has already been created by another process (e.g. jib)
  and you want to add it as a container image asset.

  **Parameters**

  - `tarballFile` — Absolute path to the tarball.
