# DockerImageAssetSource

- Source: [`core/lib/assets.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/core/lib/assets.ts#L159)
- Type last changed: v2.245.0 · 27 Mar 2026

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
const dockerImageAssetSource: cdk.DockerImageAssetSource = {
  sourceHash: 'sourceHash',

  // the properties below are optional
  assetName: 'assetName',
  directoryName: 'directoryName',
  displayName: 'displayName',
  dockerBuildArgs: {
    dockerBuildArgsKey: 'dockerBuildArgs',
  },
  dockerBuildContexts: {
    dockerBuildContextsKey: 'dockerBuildContexts',
  },
  dockerBuildSecrets: {
    dockerBuildSecretsKey: 'dockerBuildSecrets',
  },
  dockerBuildSsh: 'dockerBuildSsh',
  dockerBuildTarget: 'dockerBuildTarget',
  dockerCacheDisabled: false,
  dockerCacheFrom: [{
    type: 'type',

    // the properties below are optional
    params: {
      paramsKey: 'params',
    },
  }],
  dockerCacheTo: {
    type: 'type',

    // the properties below are optional
    params: {
      paramsKey: 'params',
    },
  },
  dockerFile: 'dockerFile',
  dockerOutputs: ['dockerOutputs'],
  executable: ['executable'],
  networkMode: 'networkMode',
  platform: 'platform',
};
```

## Properties

- `assetName`: string — Unique identifier of the docker image asset and its potential revisions.

  **Default:** no asset name

  Required if using AppScopedStagingSynthesizer.

- `directoryName`: string — The directory where the Dockerfile is stored, must be relative to the cloud assembly root.

  **Default:** Exactly one of `directoryName` and `executable` is required

- `displayName`: string — A display name for this asset.

  **Default:** The asset hash is used to display the asset

  If supplied, the display name will be used in locations where the asset
  identifier is printed, like in the CLI progress information.

- `dockerBuildArgs`: { [key: string]: string } — Build args to pass to the `docker build` command.

  **Default:** no build args are passed

  Since Docker build arguments are resolved before deployment, keys and
  values cannot refer to unresolved tokens (such as `lambda.functionArn` or
  `queue.queueUrl`).

  Only allowed when `directoryName` is specified.

- `dockerBuildContexts`: { [key: string]: string } — Build contexts to pass to the `docker build` command.

  **Default:** no additional build contexts

  Build contexts can be used to specify additional directories or images
  to use during the build. Each entry specifies a named build context
  and its source (a directory path, a URL, or a docker image).

  Only allowed when `directoryName` is specified.

- `dockerBuildSecrets`: { [key: string]: string } — Build secrets to pass to the `docker build` command.

  **Default:** no build secrets are passed

  Since Docker build secrets are resolved before deployment, keys and
  values cannot refer to unresolved tokens (such as `lambda.functionArn` or
  `queue.queueUrl`).

  Only allowed when `directoryName` is specified.

- `dockerBuildSsh`: string — SSH agent socket or keys to pass to the `docker buildx` command.

  **Default:** no ssh arg is passed

- `dockerBuildTarget`: string — Docker target to build to.

  **Default:** no target

  Only allowed when `directoryName` is specified.

- `dockerCacheDisabled`: boolean — Disable the cache and pass `--no-cache` to the `docker build` command.

  **Default:** cache is used

- `dockerCacheFrom`: [DockerCacheOption](/cdk/api/v2/docs/aws-cdk-lib.DockerCacheOption.html)[] — Cache from options to pass to the `docker build` command.

  **Default:** no cache from args are passed

- `dockerCacheTo`: [DockerCacheOption](/cdk/api/v2/docs/aws-cdk-lib.DockerCacheOption.html) — Cache to options to pass to the `docker build` command.

  **Default:** no cache to args are passed

- `dockerFile`: string — Path to the Dockerfile (relative to the directory).

  **Default:** no file

  Only allowed when `directoryName` is specified.

- `dockerOutputs`: string[] — Outputs to pass to the `docker build` command.

  **Default:** no build args are passed

- `executable`: string[] — An external command that will produce the packaged asset.

  **Default:** Exactly one of `directoryName` and `executable` is required

  The command should produce the name of a local Docker image on `stdout`.

- `networkMode`: string — Networking mode for the RUN commands during build. _Requires Docker Engine API v1.25+_.

  **Default:** no networking mode specified

  Specify this property to build images on a specific networking mode.

- `platform`: string — Platform to build for. _Requires Docker Buildx_.

  **Default:** no platform specified (the current machine architecture will be used)

  Specify this property to build images on a specific platform.

- `sourceHash`: string (required) — The hash of the contents of the docker build context.

  This hash is used
  throughout the system to identify this image and avoid duplicate work
  in case the source did not change.

  NOTE: this means that if you wish to update your docker image, you
  must make a modification to the source (e.g. add some metadata to your Dockerfile).
