我开始与docker。我需要创建一个映像与配置安装的WildFly服务器,我在我的本地存储,这个wildfly有一个java应用程序,运行在80 port
。我想创建一个容器,运行standalone.sh
文件,我可以访问它在通过locahost
网址在我的本地机器上。
当我尝试访问bin
目录时,我认为它是可以的,但当执行standalone.sh
文件时,得到此错误:/bin/sh: ./standalone.sh: No such file or directory
如何创建映像并运行容器?
这是图像结构:
/opt
├── DEJ_Wildlfy
├── wildfly-11.0.0.Final
├── appclient
├── bin
├── standalone.bat
├── standalone.conf
├── standalone.sh <--
├── ......
├── .....
我的停靠文件
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
映像创建日志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
1条答案
按热度按时间z9smfwbn1#
当您运行
docker build
时,您正在创建映像,您不希望在映像创建期间运行wildfly-CMD命令指定了在启动具有该映像的容器时要运行的默认命令。有任何理由不使用wildfly?https://hub.docker.com/r/jboss/wildfly已存在的Docker集线器映像
您可以在此处查看他们的Dockerfile:https://github.com/jboss-dockerfiles/wildfly/blob/master/Dockerfile