aws-cdk-lib.aws_ecs.ContainerImage

class ContainerImage

LanguageType name
.NETAmazon.CDK.AWS.ECS.ContainerImage
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecs#ContainerImage
Javasoftware.amazon.awscdk.services.ecs.ContainerImage
Pythonaws_cdk.aws_ecs.ContainerImage
TypeScript (source)aws-cdk-lib » aws_ecs » ContainerImage

Implemented by AssetImage, EcrImage, RepositoryImage, TagParameterContainerImage

Constructs for types of container images.

Example

import * as cdk from 'aws-cdk-lib';
import * as efs from 'aws-cdk-lib/aws-efs';

declare const myFileSystem: efs.IFileSystem;

const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
  container: new batch.EcsEc2ContainerDefinition(this, 'containerDefn', {
    image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
    memory: cdk.Size.mebibytes(2048),
    cpu: 256,
    volumes: [batch.EcsVolume.efs({
      name: 'myVolume',
      fileSystem: myFileSystem,
      containerPath: '/Volumes/myVolume',
    })],
  }),
});

Initializer

new ContainerImage()

Methods

NameDescription
bind(scope, containerDefinition)Called when the image is used by a ContainerDefinition.
static fromAsset(directory, props?)Reference an image that's constructed directly from sources on disk.
static fromDockerImageAsset(asset)Use an existing DockerImageAsset for this container image.
static fromEcrRepository(repository, tag?)Reference an image in an ECR repository.
static fromRegistry(name, props?)Reference an image on DockerHub or another online registry.
static fromTarball(tarballFile)Use an existing tarball for this container image.

bind(scope, containerDefinition)

public bind(scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfig

Parameters

  • scope Construct
  • containerDefinition ContainerDefinition

Returns

  • ContainerImageConfig

Called when the image is used by a ContainerDefinition.


static fromAsset(directory, props?)

public static fromAsset(directory: string, props?: AssetImageProps): AssetImage

Parameters

  • directory string — The directory containing the Dockerfile.
  • props AssetImageProps

Returns

  • AssetImage

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.


static fromDockerImageAsset(asset)

public static fromDockerImageAsset(asset: DockerImageAsset): ContainerImage

Parameters

  • asset DockerImageAsset — The DockerImageAsset to use for this container definition.

Returns

  • ContainerImage

Use an existing DockerImageAsset for this container image.


static fromEcrRepository(repository, tag?)

public static fromEcrRepository(repository: IRepository, tag?: string): EcrImage

Parameters

  • repository IRepository
  • tag string

Returns

  • EcrImage

Reference an image in an ECR repository.


static fromRegistry(name, props?)

public static fromRegistry(name: string, props?: RepositoryImageProps): RepositoryImage

Parameters

  • name string
  • props RepositoryImageProps

Returns

  • RepositoryImage

Reference an image on DockerHub or another online registry.


static fromTarball(tarballFile)

public static fromTarball(tarballFile: string): ContainerImage

Parameters

  • tarballFile string — Absolute path to the tarball.

Returns

  • ContainerImage

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.