# DockerImage

A Docker image.

- Source: [`core/lib/bundling.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/core/lib/bundling.ts#L339)

## Example

```ts
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

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

## Properties

- `image`: string — The Docker image.

## Methods

- `cp(imagePath: string, outputPath?: string): 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.

  **Parameters**

  - `imagePath` — the path in the Docker image.
  - `outputPath` — the destination path for the copy operation.

  **Returns:** the destination path

- `fromBuild(path: string, options?: DockerBuildOptions): DockerImage // chainable` (static) — Builds a Docker image.

  **Parameters**

  - `path` — The path to the directory containing the Docker file.
  - `options` — Docker build options.

- `fromRegistry(image: string): DockerImage // chainable` (static) — Reference an image on DockerHub or another online registry.

  **Parameters**

  - `image` — the image name.

- `run(options?: DockerRunOptions): void` — Runs a Docker image.

- `toJSON(): string` — Provides a stable representation of this image for JSON serialization.

  **Returns:** The overridden image name if set or image hash name in that order
