简体   繁体   English

高山Linux,非root用户,Java 7,Setcap:libjli.so:没有这样的文件或目录(java所需)

[英]Alpine Linux, Non-Root User, Java 7, Setcap: libjli.so: No such file or directory (needed by java)

On an Alpine Linux docker container I have created. 在我创建的Alpine Linux docker容器上。 I have set up a non-root user to run my java (jboss) server. 我已经设置了一个非root用户来运行我的java(jboss)服务器。 I am trying to give it access to run on ports < 1024. As a result, I have had to use setcap in order to provide Java with the permissions in order to run on ports < 1024. 我试图授予它在端口<1024上运行的访问权限。结果,我不得不使用setcap为了向Java提供权限以在端口<1024上运行。

Please note that authbind does not yet exist on Alpine Linux , so this is not an option. 请注意,authbind在Alpine Linux上尚不存在 ,因此这不是一个选择。 Setcap is the recommended approach. 建议使用Setcap。 See the final comment: https://github.com/gliderlabs/docker-alpine/issues/166 看到最后的评论: https : //github.com/gliderlabs/docker-alpine/issues/166

$ setcap cap_net_bind_service=+eip /opt/jdk1.7.0_51/bin/java \    
cap_net_bind_service=+eip /opt/jdk1.7.0_51/jre/bin/java

However, per Oracle, there is a known bug (and workaround) that resolves the setcap problem: http://bugs.java.com/view_bug.do?bug_id=7157699 但是,对于每个Oracle,都有一个已知的bug(和解决方法)可以解决setcap问题: http ://bugs.java.com/view_bug.do?bug_id=7157699

Basically, they recommend creating a file with the below contents. 基本上,他们建议使用以下内容创建文件。 Please note that I have installed java into "/opt/jdk1.7.0_51", and this is a 64 bit version, so the directory paths are different. 请注意,我已经将Java安装到“ /opt/jdk1.7.0_51”中,这是64位版本,因此目录路径不同。

$ mkdir -p /etc/ld.so.conf.d
$ echo "/opt/jdk1.7.0_51/jre/lib/amd64/jli" > /etc/ld.so.conf.d/java.conf
$ cat /etc/ld.so.conf.d/java.conf
/opt/jdk1.7.0_51/jre/lib/amd64/jli

However, this did not work. 但是,这没有用。 I have also tried creating links to the file: 我也尝试过创建指向文件的链接:

$ ln -s /opt/jdk1.7.0_51/jre/lib/amd64/jli/libjli.so /lib64/
$ ls -al /lib64
...
... libjli.so -> /opt/jdk1.7.0_51/jre/lib/amd64/jli/libjli.so
...
$ ls /opt/jdk1.7.0_51/jre/lib/amd64/jli/
libjli.so

This also did not work. 这也没有用。 I have tried debugging the problem as recommended in the original post using ldconfig: 我已经尝试使用ldconfig按照原始帖子中的建议调试问题:

$ ldconfig | grep libjli

This doesn't work. 这行不通。 Alpine runs a customer version of ldconfig with little documentation, so I haven't figured out exactly what to do. Alpine运行的ldconfig客户版本几乎没有文档,因此我还没有弄清楚该怎么做。

Regardless, everytime I try to debug using ldd, I still get this error: 无论如何,每次我尝试使用ldd进行调试时,我仍然会收到此错误:

$ /opt/jdk1.7.0_51/jre/bin$ ldd java
    /lib64/ld-linux-x86-64.so.2 (0x55901c23e000)
    libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x55901c23e000)
Error loading shared library libjli.so: No such file or directory (needed by java)
    libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x55901c23e000)
    libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x55901c23e000)
Error relocating java: JLI_Launch: symbol not found

I don't know what more I can possibly do at this point. 我目前不知道还能做什么。 I wanted to avoid changing our software again to get it to work under alpine, as that requires a release process and can potentially impact customers who are not yet on Docker. 我想避免再次更改我们的软件以使其在高山环境下工作,因为这需要发布过程,并且可能影响尚未使用Docker的客户。 I don't really want to touch the ports again because they are working under root. 我真的不想再次触摸这些端口,因为它们是在root用户下工作的。 I will have to go through another debug process to configure the load balancer, docker port redirection, customize recompile and debug our software, and then retest all of the above to make sure our automated scripts deploy it all correctly. 我将不得不经历另一个调试过程,以配置负载均衡器,docker端口重定向,自定义重新编译和调试我们的软件,然后重新测试以上所有内容,以确保我们的自动化脚本正确地部署了所有程序。 This is something I'd perfer to avoid. 我希望避免这种情况。

Anyone have suggestions? 有人有建议吗?

The problem with libjli.so seems to be that the Oracle JDK are built using glibc whereas Alpine uses musl libc. libjli.so的问题似乎是Oracle JDK是使用glibc构建的,而Alpine使用musl libc。

Issues for Java 8 have been opened for this, I guess they are also valid for Java 7: Java 8的问题已为此打开,我想它们对Java 7也有效:

There is this Docker image that provides glibc for Alpine, you may be able to use it as a base. 有一个为Alpine提供glibc的Docker映像 ,您也许可以将其用作基础。 It has been used to build a Oracle JDK 8 image . 它已用于构建Oracle JDK 8映像

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

相关问题 加载共享库时出错:Java中的libjli.so - Error while loading shared libraries: libjli.so in Java jar:加载共享库时出错:libjli.so [如何手动安装Java 6] - jar: error while loading shared libraries: libjli.so [How to manually install Java 6] Linux中的Java - root和non-root的不同外观类 - Java in Linux - different look and feel classes for root and non-root 无法在docker容器中加载libjli.so - Can not load libjli.so in docker container 如何以root身份启动Java程序,但降级为非root用户 - How to start Java program as root but downgrade to non-root user 如何在CentOs 6上以非root用户身份运行Java服务 - How to run java service as a non-root user on CentOs 6 Java 应用程序无法以 debian 中的非 root 用户身份连接到 mysql - Java application fails to connect to mysql as non-root user in debian 可以使用Chef以非root用户身份安装Java吗? - Can Java be installed as non-root user with Chef? 以非root用户身份使用Solaris SMF运行Java应用程序 - Running Java Application with Solaris SMF as Non-Root User 在Linux上,人们是否chroot Java Web应用程序或使用IPTables并以非root身份运行? - On Linux do people chroot a Java Web Application or use IPTables and run as non-root?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM