As per this link we can pass image name & dockerfile location to build an image in following way
docker.build("my-image:${env.BUILD_ID}", "-f ${dockerfile} ./dockerfiles")
I want to pass proxy settings to build command, Is there any way to pass it, similar to how we can pass in simple docker command.
docker build -t my-image --build-arg HTTP_PROXY=http://192.168.0.1:3128 ./dockerfiles
这对我有用:
def image = docker.build("myregistry.io/firstkey/secondkey/image:2.2.0-$BUILD_NUMBER", "--build-arg http_proxy=http://www-proxy.mycompany.com:80 --build-arg https_proxy=http://www-proxy.mycompay.com:80 --network host -f Dockerfile .")
docker.build("my-image:${env.BUILD_ID}", "--build-arg HTTP_PROXY=http://192.168.0.1:3128", "-f ${dockerfile} ./dockerfiles")
All you need to add .
in the second argument.
docker.build("my-image:${env.BUILD_ID}", "--build-arg HTTP_PROXY=http://192.168.0.1:3128 .")
您需要像这样传递它,并在它们之间留出空格作为字符串
docker.build "my-image:${env.BUILD_ID} -f ${dockerfile} ./dockerfiles"
Be aware of new lines and spaces in build args when you passing them to docker.build().
Perform trim() on them before passing to the docker.build()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.