windows - sbt 在运行 Play docker 容器时下载失败

标签 windows maven docker playframework sbt

我已经成功地为 play-java 构建了我的 docker 镜像。 .但是在尝试使用 docker run -p 0.0.0.0:9000:9000 egima/play activator run 为其生成容器时sbt 无法下载一个特定的依赖项。日志如下所示:

==== Maven2 Local: tried
  file:/root/.m2/repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0.jar
==== Apache Repository: tried  https://repository.apache.org/content/repositories/releases/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0.jar[0m
    ::::::::::::::::::::::::::::::::::::::::::::::
    ::              FAILED DOWNLOADS            ::
    :: ^ see resolution messages for details  ^ ::
    ::::::::::::::::::::::::::::::::::::::::::::::
    :: org.sonatype.sisu#sisu-guice;3.1.0!sisu-guice.jar
    ::::::::::::::::::::::::::::::::::::::::::::::

注意 tried存储库。我关注了all the different variants包括local我机器上的 maven 存储库,我从日志中确认 sbt 根据我在本地 maven 存储库中指定的内容进行检查,但没有运气。
我在两个 build.sbt 中的解析器和 /project/plugins.sbt :
resolvers ++=Seq(
    Resolver.sonatypeRepo("public"),
    Resolver.mavenLocal,
    "Apache Repository" at "https://repository.apache.org/content/repositories/releases/"
    )

我还检查了我的本地 maven 存储库以确保存在缺少的依赖项。什么不见​​了?

最佳答案

VonC在评论部分建议在 Dockerfile 中添加以下步骤:

RUN ln -s /C/Users/me/.m2 /root/.m2

我相信这个命令应该在 $MAVEN_HOME 之间建立软链接(soft link)在我的主机上和解析路径 Resolver.mavenLocal解析为 /root/.m2 .这应该是解决方案。但是,尝试后发现共享路径/c/Users/me (大写 C 不可见,不知道为什么)在 VM 内可见,但在容器内不可见。因此,在 Dockerfile 中包含该行会给我:
ln:cannot access /c/Users/me/.m2: No such file or directory

此外,即使执行 RUN ls /root会给我一个类似的错误,这意味着此时目标路径也不存在。
我自己的推论是,解决方案在于通过任何可用的方法将主机路径安装到目标路径上,我认为这是本论坛上一个很好讨论的话题。针对我的特殊情况执行挂载 docker run期间与 -v标志解决了这个问题。
这是我使用的确切命令:
docker run -v /c/Users/me/.m2:/root/.m2 -p 0.0.0.0:9000:9000 egima/play activator run

我写了a complete blog post关于他的那些需要更多信息的人。

关于windows - sbt 在运行 Play docker 容器时下载失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39636072/

相关文章:

windows - 如何使用 REST+cURL 更新 TeamCity 构建参数

.net - 如何在 PowerShell 中使用 HTML Tidy .NET DLL 包装器?

java - Maven:如何找到依赖于另一个 Artifact 的 Artifact

php - 如何将 SSH 隧道反向到 Xdebug 的远程 docker 容器?

python - Tkinter,Windows : How to view window in windows task bar which has no title bar?

java - 为团队设置 Maven Nexus Server 以共享内部构建的 jar

java - 无法在项目上执行目标 org.apache.maven.plugins :maven-compiler-plugin:3. 5.1:编译(默认编译)

git - 如何通过 Docker secret 共享 SSH key 以访问私有(private) Github 存储库?

windows - 拨号 tcp 查找 : no such host issue on docker windows desktop

windows - 在 git 中使用具有相同名称但在 Windows 中大小写不同的目录