使用 sbt-native-packager 为我的 sbt 项目获取 docker 支持时出错
Posted
技术标签:
【中文标题】使用 sbt-native-packager 为我的 sbt 项目获取 docker 支持时出错【英文标题】:Error while using sbt-native-packager to get the docker support for my sbt project 【发布时间】:2019-10-15 23:30:58 【问题描述】:我在我的 plugins.sbt 文件中添加了 sbt-native-packager,版本 1.3.15。 在 build.sbt 文件中,我使用的是 enablePlugins(DockerPligin)。 当我在 sbt shell 上运行以下命令时,我遇到了以下错误:
sbt>docker:publishLocal
错误 -->
[error] java.io.IOException: Cannot run program "docker" (in directory "C:\Users\A674634\Desktop\Scala\playProjects\akka-cluster-playground\target\docker\stage"): CreateProcess error=2, The system cannot find the file specified
[error] at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
[error] at scala.sys.process.ProcessBuilderImpl$Simple.run(ProcessBuilderImpl.scala:71)
[error] at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.run(ProcessBuilderImpl.scala:102)
[error] at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$anonfun$runBuffered$1(ProcessBuilderImpl.scala:150)
[error] at scala.runtime.java8.JFunction0$mcI$sp.apply(JFunction0$mcI$sp.java:12)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$$anon$1.buffer(DockerPlugin.scala:348)
[error] at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.runBuffered(ProcessBuilderImpl.scala:150)
[error] at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang(ProcessBuilderImpl.scala:116)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:355)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$30(DockerPlugin.scala:127)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$30$adapted(DockerPlugin.scala:125)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error] at sbt.std.Transform$$anon$4.work(System.scala:67)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] at sbt.Execute.work(Execute.scala:278)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
[error] at java.lang.ProcessImpl.create(Native Method)
[error] at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
[error] at java.lang.ProcessImpl.start(ProcessImpl.java:137)
[error] at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
[error] at scala.sys.process.ProcessBuilderImpl$Simple.run(ProcessBuilderImpl.scala:71)
[error] at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.run(ProcessBuilderImpl.scala:102)
[error] at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$anonfun$runBuffered$1(ProcessBuilderImpl.scala:150)
[error] at scala.runtime.java8.JFunction0$mcI$sp.apply(JFunction0$mcI$sp.java:12)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$$anon$1.buffer(DockerPlugin.scala:348)
[error] at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.runBuffered(ProcessBuilderImpl.scala:150)
[error] at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang(ProcessBuilderImpl.scala:116)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:355)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$30(DockerPlugin.scala:127)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$30$adapted(DockerPlugin.scala:125)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error] at sbt.std.Transform$$anon$4.work(System.scala:67)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] at sbt.Execute.work(Execute.scala:278)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[IJ]sbt:akka-cluster-playground> [error] (Docker / publishLocal) java.io.IOException: Cannot run program "docker" (in directory "C:\Users\A674634\Desktop\Scala\playProjects\akka-cluster-playground\target\docker\stage"): CreateProcess error=2, The system cannot find the file specified
【问题讨论】:
【参考方案1】:我相信您应该在项目根文件夹中执行该命令。你现在在哪个文件夹?
【讨论】:
我已将项目导入 Intellij 并从 sbt-shell 触发上述命令。 在错误日志中:in directory "C:\Users\A674634\Desktop\Scala\playProjects\akka-cluster-playground\target\docker\stage")
。尝试手动切换到根文件夹?
You need the version 1.10 or higher of the docker console client installed. SBT Native Packager doesn’t use the REST API, but instead uses the CLI directly.
检查您的本地 docker 客户端版本。以上是关于使用 sbt-native-packager 为我的 sbt 项目获取 docker 支持时出错的主要内容,如果未能解决你的问题,请参考以下文章
新贵的 daemonUser 在 sbt-native-packager 中不起作用
构建 deb 包时无法使用 sbt-native-packager 打包 cron 作业