sbt-native-packager docker:publishLocal 返回:非零退出值:125

Posted

技术标签:

【中文标题】sbt-native-packager docker:publishLocal 返回:非零退出值:125【英文标题】:sbt-native-packager docker:publishLocal returns: Nonzero exit value: 125 【发布时间】:2021-06-29 11:52:21 【问题描述】:

我正在尝试使用 sbt-native-packager 插件对我的 scala 应用程序进行 docker 化。我已在 build.sbt 中添加了适当的元素(见下文)。

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.6")

enablePlugins(JavaAppPackaging)

然后我运行(成功):

sbt stage 

然后我运行:

sbt docker:publishLocal

但它失败并出现此错误:

[error] invalid argument "my-service:3.0.3-b29+2-0d2a26e3+20210402-1141" for "-t, --tag" flag: invalid reference format
[error] See 'docker build --help'.
[error] stack trace is suppressed; run 'last Docker / publishLocal' for the full output
[error] (Docker / publishLocal) Nonzero exit value: 125
[error] Total time: 18 s, completed Apr 2, 2021 11:43:32 AM

问:这个错误是什么意思?

这是我的 build.sbt:

name := """my-service"""
organization := "my.org"
scalaVersion := "2.12.4"
    
dynverVTagPrefix in ThisBuild := false
    
lazy val root = (project in file("."))
  .enablePlugins(JavaAppPackaging)
  .enablePlugins(PlayScala)
  .enablePlugins(BuildInfoPlugin)
    .settings(
      buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
      buildInfoPackage := "controllers"
    )
libraryDependencies += guice
libraryDependencies += jdbc
libraryDependencies += ws
libraryDependencies += "mysql" % "mysql-connector-java" % "8.0.14"
libraryDependencies += "com.typesafe.play" %% "play-slick" % "3.0.3"
libraryDependencies += "javax.xml.bind" % "jaxb-api" % "2.3.1"

libraryDependencies ++= Seq(
  "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test,
  jdbc % Test
)

【问题讨论】:

【参考方案1】:

解决方案是 build.sbt 缺少版本!版本好像被当做docker标签了!

我只需要将版本添加到 build.sbt 的顶部,错误就消失了,如下所示:

name := """my-service"""
organization := "my.org"
scalaVersion := "2.12.4"
version      := "0.1.0-SNAPSHOT"

【讨论】:

以上是关于sbt-native-packager docker:publishLocal 返回:非零退出值:125的主要内容,如果未能解决你的问题,请参考以下文章

在 sbt-native-packager 中过滤映射

扩展 sbt-native-packager (Docker)

使用 sbt-native-packager 时的模糊参考

发布 sbt-native-packager 创建的 zip

如何使用 sbt-native-packager 设置 Docker Registry

任何使用 sbt-native-packager 的好例子