-
Notifications
You must be signed in to change notification settings - Fork 4.4k
(aws-ecr-assets): cannot build image correctly without docker option --network host #15516
Description
On our setup on AWS EKS runners I try to build image as follows
const image = new ecrAssets.DockerImageAsset(this, `${imageBaseName}-image`, {
directory: dockerfileDir,
file: dockerfileName,
});The problem is our CICD runners on EKS require option --network host on a building step to work correctly to install dependencies, e.g.:
docker build --network host -t $CI_PROJECT_NAME:latest .
But it seems that ecrAssets.DockerImageAsset doesn't have any way to pass other docker arguments than the listed in https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ecr-assets.DockerImageAsset.html#construct-props
Reproduction Steps
Try to build any image that requires some dependencies installed from the internet e.g.
const image = new ecrAssets.DockerImageAsset(this, `${imageBaseName}-image`, {
directory: dockerfileDir,
file: dockerfileName,
});on a runner that requires --network host e.g. on a AWS EKS pod with docker image running.
What did you expect to happen?
There is some argument e.g. string to pass extra command line options to docker build command.
What actually happened?
When docker during build tries to install some dependencies, we get errors e.g.
Cannot find a valid baseurl for repo: amzn-main/latest
Could not retrieve mirrorlist http://repo.us-west-2.amazonaws.com/latest/main/mirror.list error was
14: curl#6 - "Could not resolve host: repo.us-west-2.amazonaws.com"
Environment
- CDK CLI Version : 1.106.1
- Framework Version: 1.106.1
- Node.js Version: 14
- OS : Ubuntu 20.04
- Language (Version): TypeScript (~3.9.7)