# DockerImage

Creates `IDockerImage` instances.

Obtainable from: DockerImage.fromAsset, DockerImage.fromEcrRepository, DockerImage.fromJsonExpression, DockerImage.fromRegistry

- Source: [`aws-stepfunctions-tasks/lib/sagemaker/base-types.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sagemaker/base-types.ts#L354)
- Type last changed: v2.21.0 · 22 Apr 2022

## Example

TypeScript:

```ts
new tasks.SageMakerCreateModel(this, 'Sagemaker', {
  modelName: 'MyModel',
  primaryContainer: new tasks.ContainerDefinition({
    image: tasks.DockerImage.fromJsonExpression(sfn.JsonPath.stringAt('$.Model.imageName')),
    mode: tasks.Mode.SINGLE_MODEL,
    modelS3Location: tasks.S3Location.fromJsonExpression('$.TrainingJob.ModelArtifacts.S3ModelArtifacts'),
  }),
});
```

Python:

```python
tasks.SageMakerCreateModel(self, "Sagemaker",
    model_name="MyModel",
    primary_container=tasks.ContainerDefinition(
        image=tasks.DockerImage.from_json_expression(sfn.JsonPath.string_at("$.Model.imageName")),
        mode=tasks.Mode.SINGLE_MODEL,
        model_s3_location=tasks.S3Location.from_json_expression("$.TrainingJob.ModelArtifacts.S3ModelArtifacts")
    )
)
```

Java:

```java
SageMakerCreateModel.Builder.create(this, "Sagemaker")
        .modelName("MyModel")
        .primaryContainer(ContainerDefinition.Builder.create()
                .image(DockerImage.fromJsonExpression(JsonPath.stringAt("$.Model.imageName")))
                .mode(Mode.SINGLE_MODEL)
                .modelS3Location(S3Location.fromJsonExpression("$.TrainingJob.ModelArtifacts.S3ModelArtifacts"))
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
new SageMakerCreateModel(this, "Sagemaker", new SageMakerCreateModelProps {
    ModelName = "MyModel",
    PrimaryContainer = new ContainerDefinition(new ContainerDefinitionOptions {
        Image = DockerImage.FromJsonExpression(JsonPath.StringAt("$.Model.imageName")),
        Mode = Mode.SINGLE_MODEL,
        ModelS3Location = S3Location.FromJsonExpression("$.TrainingJob.ModelArtifacts.S3ModelArtifacts")
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
tasks.NewSageMakerCreateModel(this, jsii.String("Sagemaker"), &SageMakerCreateModelProps{
	ModelName: jsii.String("MyModel"),
	PrimaryContainer: tasks.NewContainerDefinition(&ContainerDefinitionOptions{
		Image: tasks.DockerImage_FromJsonExpression(sfn.JsonPath_StringAt(jsii.String("$.Model.imageName"))),
		Mode: tasks.Mode_SINGLE_MODEL,
		ModelS3Location: tasks.S3Location_FromJsonExpression(jsii.String("$.TrainingJob.ModelArtifacts.S3ModelArtifacts")),
	}),
})
```

## Initializer

TypeScript:

```ts
new DockerImage()
```

Python:

```python
DockerImage()
```

Java:

```java
new DockerImage()
```

C# / .NET:

```csharp
new DockerImage()
```

Golang:

```go
NewDockerImage()
```

## Methods

- `bind(task: ISageMakerTask): DockerImageConfig` — Called when the image is used by a SageMaker task.

- `fromAsset(scope: Construct, id: string, props: DockerImageAssetProps): DockerImage // chainable` (static) — Reference a Docker image that is provided as an Asset in the current app.

  **Parameters**

  - `scope` — the scope in which to create the Asset.
  - `id` — the ID for the asset in the construct tree.
  - `props` — the configuration props of the asset.

- `fromEcrRepository(repository: IRepository, tagOrDigest?: string): DockerImage // chainable` (static) — Reference a Docker image stored in an ECR repository.

  **Parameters**

  - `repository` — the ECR repository where the image is hosted.
  - `tagOrDigest` — an optional tag or digest (digests must start with `sha256:`).

- `fromJsonExpression(expression: string, allowAnyEcrImagePull?: boolean): DockerImage // chainable` (static) — Reference a Docker image which URI is obtained from the task's input.

  **Parameters**

  - `expression` — the JSONata or JSON path expression with the task input.
  - `allowAnyEcrImagePull` — whether ECR access should be permitted (set to `false` if the image will never be in ECR).

- `fromRegistry(imageUri: string): DockerImage // chainable` (static) — Reference a Docker image by it's URI.

  When referencing ECR images, prefer using `inEcr`.

  **Parameters**

  - `imageUri` — the URI to the docker image.
