我试图在Windows中使用docker工具箱运行自定义java swing GUI。我想现在容器化这个应用程序然后得到以下错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/opt/jdk1.8.0_202/jre
/lib/amd64/libawt_xawt.so: libXext.so.6: cannot open shared object file:
No such file or directory
我正在运行dockerfile。设置是:
1)安装Linux
2)安装JDK
3)复制包含JAR的文件夹
4)运行可以调出GUI的docker容器(不是linux前端,不使用vnc是首选)。
我在Windows上使用Xlaunch作为终端,并且能够使用它在docker上启动firefox。
FROM anapsix/alpine-java
COPY ./myJarFolder /home/myJarFolder
CMD ["java","-jar","/home/myJarFolder/myJarFile.jar"]
FROM alpine:3.2
MAINTAINER Anastas Dancha [...]
# Install cURL
RUN apk --no-cache add ca-certificates
# Java Version
ENV JAVA_VERSION_MAJOR 8
ENV JAVA_VERSION_MINOR 45
ENV JAVA_VERSION_BUILD 14
ENV JAVA_PACKAGE jdk
# Download and unarchive Java
RUN mkdir /opt && / curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie" && / http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_PACKAGE}-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.tar.gz | tar -xzf - -C /opt && / ln -s /opt/jdk1.${JAVA_VERSION_MAJOR}.0_${JAVA_VERSION_MINOR} /opt/jdk && / rm -rf /opt/jdk/*src.zip && /opt/jdk/lib/missioncontrol && /opt/jdk/lib/visualvm && /opt/jdk/lib/*javafx* && /opt/jdk/jre/lib/plugin.jar && /opt/jdk/jre/lib/ext/jfxrt.jar && /opt/jdk/jre/bin/javaws && /opt/jdk/jre/lib/javaws.jar && /opt/jdk/jre/lib/desktop && /opt/jdk/jre/plugin && /opt/jdk/jre/lib/deploy* && /opt/jdk/jre/lib/*javafx* && /opt/jdk/jre/lib/*jfx* && /opt/jdk/jre/lib/amd64/libdecora_sse.so && /opt/jdk/jre/lib/amd64/libprism_*.so && /opt/jdk/jre/lib/amd64/libfxplugins.so && /opt/jdk/jre/lib/amd64/libglass.so && /opt/jdk/jre/lib/amd64/libgstreamer-lite.so && /opt/jdk/jre/lib/amd64/libjavafx*.so && /opt/jdk/jre/lib/amd64/libjfx*.so
# Set environment
ENV JAVA_HOME /opt/jdk
ENV PATH ${PATH}:${JAVA_HOME}/bin
# COPY myJarFolder from local repository to the image
COPY ./myJarFolder /usr/local/myJarFolder
# Start the image with the jar file as the entrypoint
ENTRYPOINT ["java", "-jar", "usr/local/myJarFolder/myJarFile.jar"]
# EOF
$ docker run -ti --rm -e DISPLAY = 10.193.146.124:0.0 myDocker:1.0线程“main”中的异常java.lang.UnsatisfiedLinkError:/opt/jdk1.8.0_202/jre /lib/amd64/libawt_xawt.so: libXext.so.6:无法打开共享对象文件:在java.lang上java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)的java.lang.ClassLoader $ NativeLibrary.load(Native Method)中没有这样的文件或目录.ClassLoader.loadLibrary(ClassLoader.java:1824)位于java.lang.Runtime.load0(Runtime.java:809)的java.lang.System.load(System.java:1086),位于java.lang.ClassLoader $ NativeLibrary。 java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)java.lang.Runtime.loadLibrary0上的java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)中的load(本机方法)(Runtime.java:870) java.awt.Toolkit的java.lang.System.loadLibrary(System.java:1122)中的java.awt.Toolkit $ 3.run(Toolkit.java:1636),java的java.awt.Toolkit $ 3.run(Toolkit.java:1634)。 java.awt.Toolkit.loadLibraries上的security.AccessController.doPrivileged(Native Method)(Toolkit.java:1633) at java.awt.Toolkit。(Toolkit.java:1670)at java.awt.Component。(Component.java:593)at java.lang.Class.forName0(Native Method)at java.lang.Class.forName(Class .java:348)org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa der.java:56)
我在mkdir / opt行的第二个dockerfile收到权限错误。
有人可以让我知道在Windows中执行此操作的正确方法。
是否有更多的研究以及按照代码的命中和试用似乎启动了GUI,之后会出现一些错误,但这必然是由于GUI本身的其他一些问题:
FROM openjdk:8
# Set environment
ENV JAVA_HOME /opt/jdk
ENV PATH ${PATH}:${JAVA_HOME}/bin
# COPY myJarFolder from local repository to the image
COPY ./myJarFolder /usr/local/myJarFolder
# Start the image with the jar file as the entrypoint
ENTRYPOINT ["java", "-jar", "/usr/local/myJarFolder/myJarFile.jar"]
# EOF