aws-cdk-lib.DockerImage

class DockerImage

LanguageType name
.NETAmazon.CDK.DockerImage
Gogithub.com/aws/aws-cdk-go/awscdk/v2#DockerImage
Javasoftware.amazon.awscdk.DockerImage
Pythonaws_cdk.DockerImage
TypeScript (source)aws-cdk-lib » DockerImage

A Docker image.

Example

const entry = '/path/to/function';
const image = DockerImage.fromBuild(entry);

new python.PythonFunction(this, 'function', {
  entry,
  runtime: Runtime.PYTHON_3_8,
  bundling: {
    buildArgs: { PIP_INDEX_URL: "https://your.index.url/simple/", PIP_EXTRA_INDEX_URL: "https://your.extra-index.url/simple/" },
  },
});

Initializer

new DockerImage(image: string, _imageHash?: string)

Parameters

  • image string — The Docker image.
  • _imageHash string

Properties

NameTypeDescription
imagestringThe Docker image.

image

Type: string

The Docker image.

Methods

NameDescription
cp(imagePath, outputPath?)Copies a file or directory out of the Docker image to the local filesystem.
run(options?)Runs a Docker image.
toJSON()Provides a stable representation of this image for JSON serialization.
static fromBuild(path, options?)Builds a Docker image.
static fromRegistry(image)Reference an image on DockerHub or another online registry.

cp(imagePath, outputPath?)

public cp(imagePath: string, outputPath?: string): string

Parameters

  • imagePath string — the path in the Docker image.
  • outputPath string — the destination path for the copy operation.

Returns

  • string

Copies a file or directory out of the Docker image to the local filesystem.

If outputPath is omitted the destination path is a temporary directory.


run(options?)

public run(options?: DockerRunOptions): void

Parameters

  • options DockerRunOptions

Runs a Docker image.


toJSON()

public toJSON(): string

Returns

  • string

Provides a stable representation of this image for JSON serialization.


static fromBuild(path, options?)

public static fromBuild(path: string, options?: DockerBuildOptions): DockerImage

Parameters

  • path string — The path to the directory containing the Docker file.
  • options DockerBuildOptions — Docker build options.

Returns

  • DockerImage

Builds a Docker image.


static fromRegistry(image)

public static fromRegistry(image: string): DockerImage

Parameters

  • image string — the image name.

Returns

  • DockerImage

Reference an image on DockerHub or another online registry.