war 文件在 jboss wildfly docker 容器中的权限

Permission to war file in jboss wildfly docker container

我正在使用 CentOS 7。我已经从 docker hub

中提取图像
https://hub.docker.com/r/jboss/wildfly/

并从

中取出 war
https://github.com/arun-gupta/docker-for-java/tree/master/chapter2

运行下面的命令

docker run -it --name=wf -p 8080:8080 -v /home/admin/webapp.war:/opt/jboss/wildfly/standalone/deployments/webapp.war jboss/wildfly

它给我的权限在 webapp.war

上被拒绝
ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0008: Failed checking whether /opt/jboss/wildfly/standalone/deployments/webapp.war was a complete zip: java.io.FileNotFoundException: /opt/jboss/wildfly/standalone/deployments/webapp.war (Permission denied)

如何在不对 docker 文件进行任何更改的情况下授予 wepapp.war 文件权限?

尝试按照 jboss-dockerfiles/wildfly issue 19

中的建议制作自己的图片

There are two way to fix it:

Change the owner of the file after adding it to the image with chown (but this is ugly as hell...)

FROM jboss/wildfly
ADD your-awesome-app.war /opt/jboss/wildfly/standalone/deployments/ 
USER root
RUN chown jboss:jboss /opt/jboss/wildfly/standalone/deployments/*
USER jboss

Change the permissions on the host's your-awesome-app.war file:

chmod 755 your-awesome-app.war

This will make it readable to the jboss user inside of the container and it'll be able to unpack it.