如何将war文件和自定义配置添加到wildfly docker映像?

时间:2018-10-23 18:55:28

标签: java docker wildfly war

当我修改standalone.xml并将文件的路径添加到文件末尾的Deployments部分中时,我的war文件在wildfly上运行,如下所示:     。     

</socket-binding-group>
  <deployments>
    <deployment name="mywar.war" runtime-name="mywar.war">
        <fs-exploded path="/local/path/exploded/mywar.war"/>
    </deployment>
  </deployments>
 </server>

如何构建这样的Docker映像?

我从以下内容开始:

 FROM jboss/wildfly
 ADD standalone.xml /opt/jboss/wildfly/standalone/configuration
 ADD mywar.war mywar.war

其中standalone.xml具有以下内容:

  <deployment name="mywar.war" runtime-name="mywar.war">
        <fs-exploded path="/mywar.war"/>
  </deployment>

但是当我运行此docker映像时,wildfly抱怨:

 Caused by: java.io.FileNotFoundException: /mywar.war (No such file or directory)

我该如何解决?我的战争在docker映像中应该去哪里?如果我将其部署,则wildfly会抱怨存在重复的资源。

1 个答案:

答案 0 :(得分:0)

好的,我解决了

这是我添加到standalone.xml中的条目:

<deployments>
    <deployment name="mywar.war" runtime-name="mywar.war">
        <fs-exploded path="/opt/jboss/wildfly/exploded/mywar.war"/>
    </deployment>
</deployments>

这是对我有用的Dockerfile:

 FROM jboss/wildfly
 ADD standalone.xml /opt/jboss/wildfly/standalone/configuration
 ADD build/libs/exploded /opt/jboss/wildfly/exploded