Docker – Execute script on container

  docker, wildfly

I am starting with docker. I need to create an image with an configured installation of WildFly server that i have on my local storage, this wildfly has a java app that runs over 80 port.
I want to create a container that runs the standalone.sh file and i can access it at via locahost url on my local machine.

When i try to access bin directory i suposed that it is ok, but when execute the standalone.sh file, get this error:

/bin/sh: ./standalone.sh: No such file or directory

How can i create the image and runs the container?

This is the image structure:

/opt
├── DEJ_Wildlfy
    ├── wildfly-11.0.0.Final
        ├── appclient
        ├── bin
            ├── standalone.bat
            ├── standalone.conf
            ├── standalone.sh <--
            ├── ......          
        ├── .....

My DockerFile

FROM centos

#INSTALL JAVA
RUN yum -y install java-11-openjdk
RUN java -version

RUN mkdir /opt/DEJ_Wildfly/

#SET OPT AS WORK DIRECTORY
WORKDIR /opt/DEJ_Wildfly/

#COPY WILDFLY SERVER
COPY wildfly-11.0.0.Final .
RUN chmod 777 -R /opt/DEJ_Wildfly/
RUN chmod +X -R /opt/DEJ_Wildfly/
#ENV JBOSS_HOME /opt/DEJ_Wildfly/wildfly-11.0.0.Final

WORKDIR /opt/DEJ_Wildfly/wildfly-11.0.0.Final/bin/
RUN pwd
RUN ls
CMD standalone.sh -b=0.0.0.0
RUN ./standalone.sh -b 0.0.0.0
CMD tail -f /var/log/syslog
#EXPOSE 80

The log of image creation docker build --tag wildfly_dej_website:2.0 .:

Sending build context to Docker daemon  597.4MB
Step 1/14 : FROM centos
 ---> 300e315adb2f
Step 2/14 : RUN yum -y install java-11-openjdk
 ---> Using cache
 ---> f333f6149e02
Step 3/14 : RUN java -version
 ---> Using cache
 ---> 0110143899c7
Step 4/14 : RUN mkdir /opt/DEJ_Wildfly/
 ---> Running in 6ac37e57c9c0
Removing intermediate container 6ac37e57c9c0
 ---> 70331f8da178
Step 5/14 : WORKDIR /opt/DEJ_Wildfly/
 ---> Running in 9d6169492b25
Removing intermediate container 9d6169492b25
 ---> b597e72f443e
Step 6/14 : COPY wildfly-11.0.0.Final .
 ---> 44db2164e32f
Step 7/14 : RUN chmod 777 -R /opt/DEJ_Wildfly/
 ---> Running in f56c31767282
Removing intermediate container f56c31767282
 ---> 2a2e074ac50f
Step 8/14 : RUN chmod +X -R /opt/DEJ_Wildfly/
 ---> Running in 8fbfbade9abf
Removing intermediate container 8fbfbade9abf
 ---> dea87a4dc31c
Step 9/14 : WORKDIR /opt/DEJ_Wildfly/wildfly-11.0.0.Final/bin/
 ---> Running in 20dc329acd81
Removing intermediate container 20dc329acd81
 ---> 3fe555e41d7d
Step 10/14 : RUN pwd
 ---> Running in 1af150bd74bb
/opt/DEJ_Wildfly/wildfly-11.0.0.Final/bin
Removing intermediate container 1af150bd74bb
 ---> 998b9c9876a3
Step 11/14 : RUN ls
 ---> Running in d2ca989a5b0a
Removing intermediate container d2ca989a5b0a
 ---> a0dd9c8263ae
Step 12/14 : CMD standalone.sh -b=0.0.0.0
 ---> Running in 560a62f26227
Removing intermediate container 560a62f26227
 ---> ca1aed8ec311
Step 13/14 : RUN ./standalone.sh -b 0.0.0.0
 ---> Running in d9820e7fb967
/bin/sh: ./standalone.sh: No such file or directory
The command '/bin/sh -c ./standalone.sh -b 0.0.0.0' returned a non-zero code: 127

Source: Docker Questions

LEAVE A COMMENT