基于高山的Java和docker

时间:2017-02-08 12:31:49

标签: java docker glibc alpine

我有一个Java应用程序,我想在高山运行。它有一个GUI。我正在建立一个基于alpine / latest的图像。安装了所有必需的软件包后,当我运行应用程序时,我看到以下错误:

[ERROR] [system.err] GLib (gthread-posix.c): Unexpected error from C library during 'pthread_cond_init': Invalid argument.  Aborting.

对我而言似乎与glibc库的版本兼容性问题。 有关安装的glib的信息:

bash-4.3# apk info glib
glib-2.50.2-r0 description:
Common C routines used by Gtk+ and other libs
glib-2.50.2-r0 webpage:
http://www.gtk.org
glib-2.50.2-r0 installed size:
2957312
bash-4.3# 

不确定它是否相关,但在libjvm.so上执行ldd会产生以下内容:

bash-4.3# ldd /opt/jdk1.8.0_112/jre/lib/amd64/server/libjvm.so
    ldd (0x7f3257095000)
    libm.so.6 => ldd (0x7f3257095000)
    libdl.so.2 => ldd (0x7f3257095000)
    libpthread.so.0 => ldd (0x7f3257095000)
    libc.so.6 => ldd (0x7f3257095000)
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /opt/jdk1.8.0_112/jre/lib/amd64/server/libjvm.so)
Error relocating /opt/jdk1.8.0_112/jre/lib/amd64/server/libjvm.so: __getpagesize: symbol not found
Error relocating /opt/jdk1.8.0_112/jre/lib/amd64/server/libjvm.so: gnu_get_libc_release: symbol not found
Error relocating /opt/jdk1.8.0_112/jre/lib/amd64/server/libjvm.so: __isnan: symbol not found
Error relocating /opt/jdk1.8.0_112/jre/lib/amd64/server/libjvm.so: gnu_get_libc_version: symbol not found
Error relocating /opt/jdk1.8.0_112/jre/lib/amd64/server/libjvm.so: dlvsym: symbol not found
bash-4.3# 

我还对我试图运行的命令进行了操作:

access("/opt/jdk1.8.0_112/lib/amd64/libjava.so", F_OK) = -1 ENOENT (No such file or directory)
access("/opt/jdk1.8.0_112/jre/lib/amd64/libjava.so", F_OK) = 0
open("/opt/jdk1.8.0_112/jre/lib/amd64/jvm.cfg", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=627, ...}) = 0
read(3, "# Copyright (c) 2003, 2013, Orac"..., 4096) = 627
read(3, "", 4096)                       = 0
close(3)                                = 0
stat("/opt/jdk1.8.0_112/jre/lib/amd64/server/libjvm.so", {st_mode=S_IFREG|0755, st_size=16989811, ...}) = 0
getgid()                                = 0
getegid()                               = 0
getuid()                                = 0
geteuid()                               = 0
futex(0x7f7c894f90c8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
open("/opt/jdk1.8.0_112/jre/lib/amd64/server/libjvm.so", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\350!\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=16989811, ...}) = 0
mmap(NULL, 16717288, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f7c87f68000
mprotect(0x7f7c88c36000, 2097152, PROT_NONE) = 0
mmap(0x7f7c88e36000, 888832, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xcce000) = 0x7f7c88e36000
mmap(0x7f7c88f0f000, 304616, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f7c88f0f000
close(3)                                = 0
open("/opt/jdk1.8.0_112/bin/../lib/amd64/jli/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/opt/jdk1.8.0_112/bin/../lib/amd64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/glibc-compat/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260U\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1059160, ...}) = 0
mmap(NULL, 3154224, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f7c87c65000
mprotect(0x7f7c87d67000, 2093056, PROT_NONE) = 0
mmap(0x7f7c87f66000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x101000) = 0x7f7c87f66000
close(3)                                = 0
mprotect(0x7f7c87f66000, 4096, PROT_READ) = 0
mmap(NULL, 1052672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f7c89a48000
mprotect(0x7f7c89a48000, 4096, PROT_NONE) = 0
clone(child_stack=0x7f7c89b47ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f7c89b489d0, tls=0x7f7c89b48700, child_tidptr=0x7f7c89b489d0) = 337
futex(0x7f7c89b489d0, FUTEX_WAIT, 337, NULLGLib (gthread-posix.c): Unexpected error from C library during 'pthread_cond_init': Invalid argument.  Aborting.
 <unfinished ...>
+++ killed by SIGABRT +++

任何提示?

2 个答案:

答案 0 :(得分:0)

您使用https://github.com/anapsix/docker-alpine-java吗? 它应该开箱即用。 如果你只使用普通的高山图像https://hub.docker.com/_/alpine/,它可能会遗漏一些java所需的东西。

您是否使用java.awt.headless = true启动应用程序?

对于JavaFX,请参阅JavaFx in headless mode

您应该安装xvfb并重试。

答案 1 :(得分:0)

我最近在Alpine Docker图片中遇到过openjdk8的不良体验 vanilla图像加上java8生成了一些核心转储而没有明确的原因。 我将相同的设置移动到openjdk Docker镜像(debian)并且运行顺利。