How to add JBOSS_HOME in dockerfile and run the jboss container

2k Views Asked by At

I want to add my custom JBOSS_HOME but when i run my dockerfile it give me an error.

JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.

Unable to access jarfile

/home/shri/opt/jboss/wildfly/jboss-modules.jar

MY Dockerfile is:-

FROM jboss/wildfly   
MAINTAINER shri  
USER root  
ENV JBOSS_HOME /home/shri/opt/jboss/wildfly  
RUN mkdir -p  $JBOSS_HOME  
ADD jboss-modules.jar /home/shri/jboss/wildfly/  
USER jboss  

build dockerfile using:

docker build -t jboss .

Run dockerfile using:

docker run -p 8080:8080 jboss
2

There are 2 best solutions below

2
On

It's not obvious what you are trying to achieve.

The WildFly in the parent image you are building from is located in the /opt/jboss/wildfly, but you are

  • adding a custom jboss-modules.jar to /home/shri/jboss/wildfly/
  • and setting JBOSS_HOME to /home/shri/opt/jboss/wildfly which obviously doesn't exist.

If you want just to use the custom jboss-modules.jar, then the simplest is to overwrite the original one in /opt/jboss/wildfly/jboss-modules.jar and leave the JBOSS_HOME unchanged.

You can also have a look at Dockerfile for wildfly on git here: https://github.com/jboss-dockerfiles/wildfly/blob/master/Dockerfile

0
On

Dockerfile is fine, It is adding your custom jar file as well, Then where is the Problem?

I think the base image you are using setting working directory. to /opt/jboss and there is a default jboss file. I think by default it is picking this jar file.

Try changing working directory, Add this line (or similar) to your docker file after setting ENV and then try

WORKDIR ${JBOSS_HOME}