I'm building and pushing a docker image to ecr as part of a jenkins pipeline.
environment { registry = "11111111111.dkr.ecr.eu-west-2.amazonaws.com/bar" registryCredential = 'ecr-creds' stages { stage('Docker Build') { steps { dir('assets/'){ script { dockerImage = docker.build registry } } } } stage('Docker Deploy') { steps{ script { docker.withRegistry("https://" + registry, "ecr:eu-west-2:" + registryCredential ) { dockerImage.push() } } } } However, I need to add the flag --network host as part of my docker build argument as its the only way I'm able to successfully build the image.
Doing this sh "docker build -t $registry . --network host" works, but then the Docker Deploy stage fails with a No such property: dockerImage error which is understandable as dockerImage isn't defined anymore.
Is there a way to add the --network host flag?