linux – 从官方jboss / wildfly图像创建自定义图像时,standalone-full.xml的’权限被拒绝’错误

我正在努力构建一个源自官方jboss / wildfly图像的自定义图像.

如果我只是添加.war文件并运行它,它工作得很好,但当我尝试添加自定义standalone-full.xml文件时会出现问题

这是我的Dockerfile:

FROM jboss/wildfly:10.1.0.Final

COPY standalone-full.xml
/opt/jboss/wildfly/standalone/configuration/standalone-full.xml

COPY sample.war /opt/jboss/wildfly/standalone/deployments/

CMD [“/opt/jboss/wildfly/bin/standalone.sh”, “-c”,
“standalone-full.xml”, “-b”, “0.0.0.0”, “-bmanagement”, “0.0.0.0”]

这是我的源目录:

link to screenshot of ls -la command inside the source directory

根据建议,我给了standalone-full.xml文件755的权限.

但是,使用以下命令构建映像后:

docker build -t sample-app .

并运行图像如下:

docker run -it -p 8080:8080 -p 80:80 -p 443:443 sample-app

我收到以下错误:

13:18:06,274 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.undertow.listener.default: org.jboss.msc.service.StartException in service jboss.undertow.listener.default: WFLYUT0082: Could not start 'default' listener.
    at org.wildfly.extension.undertow.ListenerService.start(ListenerService.java:153)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Permission denied
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:433)
    at sun.nio.ch.Net.bind(Net.java:425)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.xnio.nio.NioXnioWorker.createTcpConnectionServer(NioXnioWorker.java:190)
    at org.xnio.XnioWorker.createStreamConnectionServer(XnioWorker.java:243)
    at org.wildfly.extension.undertow.HttpListenerService.startListening(HttpListenerService.java:126)
    at org.wildfly.extension.undertow.ListenerService.start(ListenerService.java:142)

我执行进入正在运行的容器来查看独立文件的文件权限:

link to screenshot of ls -la command inside the container’s /opt/jboss/wildfly/standalone/configuration/ directory

如果我在运行CMD指令之前将用户更改为root,我能够运行应用程序,但这不是一个好的做法我认为:

FROM jboss/wildfly:10.1.0.Final

COPY standalone-full.xml
/opt/jboss/wildfly/standalone/configuration/standalone-full.xml

COPY sample.war /opt/jboss/wildfly/standalone/deployments/

USER root

CMD [“/opt/jboss/wildfly/bin/standalone.sh”, “-c”,
“standalone-full.xml”, “-b”, “0.0.0.0”, “-bmanagement”, “0.0.0.0”]

如何正确设置独立文件的权限,以便我可以使用’jboss’用户运行应用程序?

我还尝试更改Dockerfile中的权限,如下所示,以匹配其他文件的权限:

FROM jboss/wildfly:10.1.0.Final

USER root

COPY standalone-full.xml
/opt/jboss/wildfly/standalone/configuration/standalone-full.xml

RUN chown jboss:root /opt/jboss/wildfly/standalone/configuration/standalone-full.xml

USER jboss

COPY sample.war /opt/jboss/wildfly/standalone/deployments/

CMD [“/opt/jboss/wildfly/bin/standalone.sh”, “-c”,
“standalone-full.xml”, “-b”, “0.0.0.0”, “-bmanagement”, “0.0.0.0”]

但是,权限没有得到应用,我仍然得到相同的错误.
任何人都可以指出我正确的方向,我在哪里犯了错误?

我正在使用Docker版本17.06.0-ce和overlay2存储驱动程序

解决方法:

您已将wildfly实例配置为侦听TCP / IP端口号< 1024. 实际上是端口80和443. 通常只有root用户才有权在任何基于unix的操作系统上执行此操作,包括Linux.

上一篇:java – 如何从WildFly中取消部署所有工件?


下一篇:java – JBoss在Windows上运行良好吗?