简体   繁体   English

在 Docker 容器中运行 Java Gui 应用程序

[英]Run Java Gui Application in Docker Container

i want to run a Java GUI application inside a docker container which then will be hosted on my Ubuntu Server.我想在 docker 容器中运行一个 Java GUI 应用程序,然后该容器将托管在我的 Ubuntu 服务器上。 I want to access the application through a web browser.我想通过 Web 浏览器访问该应用程序。

Here is the application i want to put inside the Docker Container: https://github.com/Dabomstew/universal-pokemon-randomizer这是我想放入 Docker 容器的应用程序: https : //github.com/Dabomstew/universal-pokemon-randomizer

Would i have to add a custom UI for the app in the browser, or is it possible to use the java gui inside the browser?我是否必须在浏览器中为应用程序添加自定义 UI,或者是否可以在浏览器中使用 java gui?

I have seen this done with a few other projects so i think it should be possible.我已经在其他一些项目中看到了这一点,所以我认为这应该是可能的。 I am not sure how exactly this was done and how much work this would require though...我不确定这是如何完成的以及这需要多少工作......

Here are some examples of java gui applications running in a docker container:以下是在 docker 容器中运行的 java gui 应用程序的一些示例:

I am new to docker, i hope anyone can help me :) Thanks!我是 docker 新手,我希望任何人都可以帮助我 :) 谢谢!

Browsers can run a very limited set of language runtimes;浏览器可以运行一组非常有限的语言运行时; essentially only Javascript and things that can be recompiled into Javascript.本质上只有 Javascript 和可以重新编译成 Javascript 的东西。 There's not a generic way to take a running desktop application and republish it into a browser.没有一种通用的方法可以将正在运行的桌面应用程序重新发布到浏览器中。

Docker here is just an intermediate layer.这里的Docker只是一个中间层。 It's very good for things like HTTP servers that are self-contained except for a network port;这对于像 HTTP 服务器这样除了网络端口之外都是自包含的东西非常好; okay for command-line applications (if you don't mind running it as root with a command line three times as long, it works fine);可以用于命令行应用程序(如果您不介意以 root 身份运行它,并使用三倍长的命令行,它可以正常工作); and bad for GUI applications (works only on Linux, the command lines are long and arcane, and things are still highly likely to look different).并且对 GUI 应用程序不利(仅适用于 Linux,命令行又长又神秘,而且看起来很可能会有所不同)。 It doesn't provide any magic to cross these layers.它没有提供任何魔法来跨越这些层。

You might be able to find some existing software that can fill some of these gaps;您也许能够找到一些可以填补其中一些空白的现有软件; perhaps a browser-based X server, or maybe one of the full-blown VM systems can display a VM's desktop in a browser, or maybe you might be able to use the all-but-dead Java applet system, or maybe there's a Java layer that provides a websocket-based client and lets you run your Java-native GUI application with minor modifications.也许一个基于浏览器的 X 服务器,或者一个成熟的 VM 系统可以在浏览器中显示一个 VM 的桌面,或者也许你可以使用几乎死了的 Java 小程序系统,或者也许有一个 Java层,它提供了一个基于 websocket 的客户端,并让您只需稍作修改即可运行您的 Java 原生 GUI 应用程序。

I'd encourage you to first make your application work, and solve the "how do I actually make it appear the way I want" problem, and only then bring in Docker if it's appropriate.我鼓励你首先让你的应用程序工作,并解决“我如何真正让它以我想要的方式出现”的问题,然后才在合适的情况下引入 Docker。 The layer of separation it provides can make many things more difficult especially while you're actively developing or exploring an unknown space.它提供的隔离层会使许多事情变得更加困难,尤其是当您正在积极开发或探索未知空间时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM