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

sbt-native-packager docker:publishLocal returns: Nonzero exit value: 125

我正在尝试使用 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
)

解决方法是 build.sbt 缺少版本!该版本似乎被用作 docker 标签!

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

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