class ContainerImage
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.ECS.ContainerImage |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsecs#ContainerImage |
Java | software.amazon.awscdk.services.ecs.ContainerImage |
Python | aws_cdk.aws_ecs.ContainerImage |
TypeScript (source) | aws-cdk-lib » aws_ecs » ContainerImage |
Implemented by
Asset
, Ecr
, Repository
, Tag
Constructs for types of container images.
Example
declare const mySecret: secretsmanager.ISecret;
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,
secrets: {
MY_SECRET_ENV_VAR: batch.Secret.fromSecretsManager(mySecret),
}
}),
});
Initializer
new ContainerImage()
Methods
Name | Description |
---|---|
bind(scope, containerDefinition) | Called when the image is used by a ContainerDefinition. |
static from | Reference an image that's constructed directly from sources on disk. |
static from | Use an existing DockerImageAsset for this container image. |
static from | Reference an image in an ECR repository. |
static from | Reference an image on DockerHub or another online registry. |
static from | Use an existing tarball for this container image. |
bind(scope, containerDefinition)
public bind(scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfig
Parameters
- scope
Construct
- containerDefinition
Container
Definition
Returns
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
Asset
Image Props
Returns
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
Docker
— TheImage Asset DockerImageAsset
to use for this container definition.
Returns
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
— If you don't specify this parameter,latest
is used as default.
Returns
Reference an image in an ECR repository.
static fromRegistry(name, props?)
public static fromRegistry(name: string, props?: RepositoryImageProps): RepositoryImage
Parameters
- name
string
- props
Repository
Image Props
Returns
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
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.