cdk-docker-image-deployment

raw JSON →
0.0.986 verified Fri May 01 auth: no python

CDK construct library to copy Docker images between repositories (ECR, DockerHub etc.) and optionally tag them. Useful for cross-account or cross-region deployments. Current version: 0.0.986. Released frequently.

pip install cdk-docker-image-deployment
error ModuleNotFoundError: No module named 'cdk-docker-image-deployment'
cause Trying to import with hyphens instead of underscores.
fix
Install with 'pip install cdk-docker-image-deployment' and import as 'cdk_docker_image_deployment'.
error jsii.errors.JSIIError: Your application requires a newer version of the AWS CDK library. This version is ...
cause Incompatible CDK version (e.g., using v1 with v2 construct).
fix
Update your CDK app to aws-cdk-lib v2.
breaking CDK v1 support dropped. Use aws-cdk-lib v2.
fix Ensure your CDK app uses aws-cdk-lib (v2) instead of @aws-cdk/core.
gotcha The library requires Docker to be running during deployment synthesis (not cdk deploy but during cdk synth or pipeline build).
fix Make sure Docker is running in the environment where you run cdk synth.
gotcha Source.docker_hub() pulls from Docker Hub by default, but you must specify a tag; 'latest' is not automatically applied.
fix Always include a tag like 'nginx:latest' or 'nginx:1.21'.

Deploys a Docker image from DockerHub to ECR. Replace placeholders with actual account ID and region.

from aws_cdk import App, Stack
from cdk_docker_image_deployment import DockerImageDeployment, Source

app = App()
stack = Stack(app, "MyStack")

DockerImageDeployment(stack, "DeployImage",
    source=Source.docker_hub("public.ecr.aws/docker/library/nginx:latest"),
    destination=DockerImageName("<account-id>.dkr.ecr.<region>.amazonaws.com/my-nginx:latest")
)

app.synth()