加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Jenkins Pipeline docker.build()给出错误’“docker build”只

发布时间:2020-12-16 03:53:02 所属栏目:安全 来源:网络整理
导读:使用这个最小的Jenkins管道脚本 node { docker.build("foo","--build-arg x=y")} 我遇到了一个令人困惑的错误 docker build requires exactly 1 argument(s). 但根据文档,docker.build()的签名是build(image [,args])(来自Jenkins / job / dockerbug / pipel

使用这个最小的Jenkins管道脚本

node {
  docker.build("foo","--build-arg x=y")
}

我遇到了一个令人困惑的错误

“docker build” requires exactly 1 argument(s).

但根据文档,docker.build()的签名是build(image [,args])(来自Jenkins / job / dockerbug / pipeline-syntax / globals#docker)

build(image[,args])

Runs docker build to create and tag the specified
image from a Dockerfile in the current directory. Additional args may
be added,such as '-f Dockerfile.other --pull --build-arg
http_proxy=http://192.168.1.1:3128 .'
. Like docker build,args must
end with the build context. Returns the resulting Image object.
Records a FROM fingerprint in the build.

这是怎么回事?

最佳答案
我的困惑是因为错误信息实际上来自Docker,而不是Jenkins.

如果您未指定构建上下文,则Docker会出现此错误(如上文中所述).

修复只是添加.根据示例到args参数的末尾,例如:

node {
  docker.build("foo","--build-arg x=y .")
}

见docker: “build” requires 1 argument. See ‘docker build –help’

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读