IntelliJ:使用 docker jvm 还是 docker maven?

2022-01-20 00:00:00 docker ide intellij-idea java maven

我有一个 docker/jvm 实例,我从命令行使用它来编译和运行 java 代码.IntelliJ 的项目配置要求我指向文件系统上的 jvm.

I have a docker/jvm instance, which I use from the command line to compile and run java code. IntelliJ's project config requires me to point at a jvm on the filesystem.

所以,我想知道,我可以将 intellij 配置为使用这个 docker 容器吗?我想我可以配置一个 docker 容器,让它保持运行,并挂载/共享它的文件系统,但我不希望这样——我想使用我的临时容器实例.

So, I was wondering, can I configure intellij to use this docker container? I suppose I could configure a docker container, keep it running, and mount/share its filesystem, but I don't want that -- I want to use my ephemeral container instance.

我对使用 maven 有同样的想法——我可以在 intellij 中使用 maven 的 docker 实例而不安装文件系统吗?同样,intellij 似乎需要一个指向 maven 文件系统位置的指针,所以这似乎有问题.

I have the same idea for using maven -- can I use a docker instance of maven without mounting the filesystem, from within intellij? Again, intellij seems to require a pointer to a filesystem location for maven, so this seems problematic.

有没有人知道这是否可行,或者如何配置这样的东西?

Does anyone have any clue if this is possible, or how to go about configuring such a thing?

推荐答案

同样,intellij 似乎需要一个指向 maven 文件系统位置的指针,所以这似乎有问题.

Again, intellij seems to require a pointer to a filesystem location for maven, so this seems problematic.

应用程序使用另一个容器化的唯一方法是将该应用程序本身放在同一个容器中(或从另一个容器挂载数据卷,这样可以避免挂载本地文件系统)

The only way for an application to use another containerized one would be for that application itself to be in the same container (or to mount a data volume from another container, which avoids mounting the local filesystem)

所以使用类似 dlsniper/docker-intellij/(用于 go,但很容易适应 java)可以工作,并允许 IntelliJ container 到

  • 共享 X11 套接字以便在主机桌面上查看容器化应用程序,
  • 使用数据卷(同样,无需直接挂载本地文件系统):
    • jvm 的数据量
    • java 源的数据量
    • share the X11 socket in order to see the containerized application on the host desktop,
    • uses data volumes (again, without mounting a local filesystem directly):
      • data-volume for the jvm
      • data-volume for the java sources

相关文章