We use a variety of CDK containers at Sykes Cottages across most of our platforms, but due to a lack of official and maintained images we have introduced our own. All of our CDK images are based off the Base Sykes image which uses the official Ubuntu Docker image. We opted for this path to utilise aptitude so we could manage packages easier and utilise the package integrity verification that comes with apititude.
All images contain JQ, Docker and the AWS CLI to support various CDK features.
For the AWS CLI features you will need to define your AWS credentials by passing them to the container via the .aws
mounts e.g.
docker run \
-v ~/.aws/credentials:/root/.aws/credentials \
-v ~/.aws/config:/root/.aws/config \
sykescottages/cdk:latest \
aws sts get-caller-identity
The mounting user can be variable depending on what user you run the container with.
CDK allows you to build docker images for ECR repositories and to utilise this you will need docker available. As you can't run docker directly within a container you will need to pass the docker sock to the container through a volume e.g.
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
sykescottages/cdk:latest \
docker --version
The addition of JQ was to expand on the AWS CLI's version of JQ which is limited.
docker run \
sykescottages/cdk:latest \
jq --version
- 1.203.0 (Deprecated) -
sykescottages/cdk:1
- 2.89.0 (Current) -
sykescottages/cdk:2
Pulling an image:
docker pull sykescottages/cdk:version
Running a container:
docker run -it \
-v ~/.aws/credentials:/root/.aws/credentials \
-v ~/.aws/config:/root/.aws/config \
-v /var/run/docker.sock:/var/run/docker.sock \
--privileged \
sykescottages/cdk:latest --version
Building from this image simply reference it as part of your Dockerfile:
FROM sykescottages/cdk:version
# ... Your configuration
version: '3'
services:
cdk:
image: sykescottages/cdk:latest
volumes:
- .:/code
- ~/.aws/credentials:/root/.aws/credentials
- ~/.aws/config:/root/.aws/config
- /var/run/docker.sock:/var/run/docker.sock
working_dir: /code
privileged: true
All testing is done in the form of a SUT containers which is run by the Docker Hub (see Automated repository tests for more information) and runs a variety of shell scripts.
Contributions are welcome, but please adhere to the CONTRIBUTION.MD. Also, if you could ensure that there are tests with every modification of the Dockerfiles to verify that your changes work.