Docker允许在
docker build
命令中使用--pull
标志,例如:docker build --pull -t myimage .
。 我该如何在我的Jenkinsfile
管道脚本中强制拉取基础镜像?这样我想确保构建始终使用最新的容器映像,而不受本地版本的影响。node('docker') {
def app
stage('Checkout') {
checkout scm
}
stage('Build image') {
docker.withRegistry('https://myregistry.company.com', 'dcr-jenkins') {
app = docker.build "myimage"
}
}
stage('Publish image') {
docker.withRegistry('https://myregistry.company.com', 'dcr-jenkins') {
app.push("latest")
}
}
}