我尝试使用以下命令将scala构建发布到docker注册表:
./sbt "; set dockerRepository := Some(\"registryname/project\"); docker:publish"
我指定了dockerRepository但是在运行命令时会抛出以下错误:
[error] You cannot push a "root" repository. Please rename your repository to <user>/<repo> (ex: <user>/example)
java.lang.RuntimeException: Repository for publishing is not specified.
[error] (all/*:publishConfiguration) Repository for publishing is not specified.
[error] (server/docker:publish) Nonzero exit value: 1
[error] (config/*:publishConfiguration) Repository for publishing is not specified.
[error] Total time: 63 s, completed 01/09/2015 10:48:04 AM
当我查看我的本地docker注册表时,我可以看到它编译了docker镜像,但没有为docker注册表名称添加前缀:
docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
example 0.0.1 SNAPSHOT a6eb8942aa9f 8 minutes ago 1.136 GB
所以它似乎没有接受我在命令上设置的dockerRepository变量,这也在构建日志中:
[15:32:58][Step 4/5] [info] Loading project definition from /build/project
[15:33:01][Step 4/5] [info] Set current project to example (in build file:/build/)
[15:33:06][Step 4/5] [info] Defining {.}/*:dockerRepository
[15:33:06][Step 4/5] [info] The new value will be used by no settings or tasks.
[15:33:06][Step 4/5] [info] Reapplying settings...
答案 0 :(得分:0)
摘自Alex Laverty的评论:
在build.sbt
中:
dockerRepository in ThisBuild := Some("docker.io")
或在具有子模块的项目中:
lazy val server = (project in file("server"))
.settings(dockerRepository := Some("docker.io"),
dockerUsername := Some("pame"),
...)
然后:
sbt docker:publish