March 30th, 2022

Here’s a Dockerfile I’m using for local cdk development. It installs Docker, CDK and the AWS CLI.

It supports bundling with cdk synth and npm test.

It’s important that your working directory in your container is the same path as it is on your host machine. I check out code to /home/scarab05/sandbox.


FROM node:16

RUN apt-get update && apt-get -y install ca-certificates curl gnupg lsb-release 
RUN curl -fsSL | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update && apt-get -y install docker-ce docker-ce-cli && apt-get clean

RUN curl "" -o "" && unzip && ./aws/install

RUN npm install -g aws-cdk

USER node
WORKDIR /home/scarab05/sandbox
CMD /bin/bash


I build it as follows

docker build -t cdk-build .

I run it as follows

docker run -v /var/run/docker.sock:/var/run/docker.sock \
    -v /home/scarba05/sandbox:/home/scarba05/sandbox \
    -v /tmp:/tmp \
    -it cdk-build /bin/bash