我试图在构建后运行docker save以将docker映像存储在.tar文件中
script.sh的片段:
#build new docker image
$docker build -f Dockerfile -t "$module":$imageversion .
#creating a copy
$docker save "$module":$imageversion > "$module".tar
ls -al
我正在并行运行上述脚本以同时构建模块:
Jenkinsfile:
pipeline {
agent {
label 'DOCKER_BUILD'
}
stages {
stage("Build") {
parallel {
stage("Build module foo") {
steps {
script {
sh "chmod +x script.sh"
sh """
./script.sh foo 1.0
"""
}
}
}
stage("Build module bar") {
steps {
script {
sh "chmod +x script.sh"
sh """
./script.sh bar 1.0
"""
}
}
}
}
}
}
}
以下是结果:
Step 1/3 : FROM rhel7.5
---> 7b875638cfd8
Step 2/3 : COPY foo /
---> 03486e60a155
Removing intermediate container 294374c335e2
Step 3/3 : CMD /foo
---> Running in b443c0353f03
---> 7cf9cea4eb63
Removing intermediate container b443c0353f03
Successfully built 7cf9cea4eb63
Error response from daemon: open /var/lib/docker/devicemapper/mnt/ea79ca596a1bdf10526762edf47ac439e3a54d3d327ee3b19b9d11e589299298/rootfs/root/buildinfo/Dockerfile-rhel7-7.5-433: no such file or directory
drwxr-xr-x 3 pdcifadm dcifgrp 4096 Jun 13 17:09 .
drwxr-xr-x 31 pdcifadm dcifgrp 4096 Jun 13 17:05 ..
-rwxr-xr-x 1 pdcifadm dcifgrp 15370790 Jun 13 17:07 foo
-rw-r--r-- 1 pdcifadm dcifgrp 0 Jun 13 17:09 module-foo.tar
-rw-r--r-- 1 pdcifadm dcifgrp 74 Jun 13 17:07 Dockerfile
-rwxr-xr-x 1 pdcifadm dcifgrp 105 Jun 13 17:07 script.sh
请注意,.tar文件有0个字节。查看Build module bar
日志时得到的结果相同。
我尝试测试更多的并行构建,但发现docker save
有时可以按某些步骤预期工作。
按顺序运行该构建按预期运行。
我在这里错过了什么吗?也许是代理或工作区问题?
谢谢!
干杯!