ContainerImage Class
Constructs for types of container images.
Example
ts
declare const myFileSystem: efs.IFileSystem;
declare const myJobRole: iam.Role;
myFileSystem.grantRead(myJobRole);
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',
useJobRole: true,
})],
jobRole: myJobRole,
}),
});
Initializer
ts
new ContainerImage()
python
ContainerImage()
java
new ContainerImage()
csharp
new ContainerImage()
go
NewContainerImage()
Methods
bind(scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfigdef bind(self, scope: Construct, container_definition: ContainerDefinition) -> ContainerImageConfigpublic ContainerImageConfig bind(Construct scope, ContainerDefinition containerDefinition)public ContainerImageConfig Bind(Construct scope, ContainerDefinition containerDefinition)func Bind(Scope Construct, ContainerDefinition ContainerDefinition) ContainerImageConfig#Called when the image is used by a ContainerDefinition.
fromAsset(directory: string, props?: AssetImageProps): AssetImage@staticmethod def from_asset(directory: str, props: typing.Optional[AssetImageProps] = None) -> AssetImagepublic static AssetImage fromAsset(String directory, AssetImageProps props)public static AssetImage FromAsset(string directory, AssetImageProps? props = null)func FromAsset(Directory *string, Props AssetImageProps) AssetImagestatic#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.
1 parameter
Parameters
directorydirectorydirectorydirectoryDirectory— The directory containing the Dockerfile.
fromDockerImageAsset(asset: DockerImageAsset): ContainerImage // chainable@staticmethod def from_docker_image_asset(asset: DockerImageAsset) -> ContainerImagepublic static ContainerImage fromDockerImageAsset(DockerImageAsset asset)public static ContainerImage FromDockerImageAsset(DockerImageAsset asset)func FromDockerImageAsset(Asset DockerImageAsset) ContainerImagestatic#Use an existing `DockerImageAsset` for this container image.
1 parameter
Parameters
assetassetassetassetAsset— TheDockerImageAssetto use for this container definition.
fromEcrRepository(repository: IRepository, tag?: string): EcrImage@staticmethod def from_ecr_repository(repository: IRepository, tag: typing.Optional[str] = None) -> EcrImagepublic static EcrImage fromEcrRepository(IRepository repository, String tag)public static EcrImage FromEcrRepository(IRepository repository, string? tag = null)func FromEcrRepository(Repository IRepository, Tag *string) EcrImagestatic#Reference an image in an ECR repository.
1 parameter
Parameters
tagtagtagtagTag— If you don't specify this parameter,latestis used as default.
fromRegistry(name: string, props?: RepositoryImageProps): RepositoryImage@staticmethod def from_registry(name: str, props: typing.Optional[RepositoryImageProps] = None) -> RepositoryImagepublic static RepositoryImage fromRegistry(String name, RepositoryImageProps props)public static RepositoryImage FromRegistry(string name, RepositoryImageProps? props = null)func FromRegistry(Name *string, Props RepositoryImageProps) RepositoryImagestatic#Reference an image on DockerHub or another online registry.
fromTarball(tarballFile: string): ContainerImage // chainable@staticmethod def from_tarball(tarball_file: str) -> ContainerImagepublic static ContainerImage fromTarball(String tarballFile)public static ContainerImage FromTarball(string tarballFile)func FromTarball(TarballFile *string) ContainerImagestatic#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.
1 parameter
Parameters
tarballFiletarball_filetarballFiletarballFileTarballFile— Absolute path to the tarball.