问题描述
有什么方法可以将 .war 文件部署到在 docker 容器内运行的 Jboss-as7 中
Is there some way to deploy .war files into Jboss-as7 running inside a docker container
因为我的 jboss 服务器在 docker 提交后似乎失败了.
Because my jboss server seems to fail after a docker commit.
Could not rename /usr/local/share/jboss/standalone/configuration/standalone_xml_history/current to /usr/local/share/jboss/standalone/configuration/standalone_xml_history/20140107-050049692
我试过了
chmod +w usr/local/share/jboss/standalone/configuration/standalone_xml_history
参考:
https://docs.jboss.org/author/display/AS7/配置+文件+历史
现在,如果我停止 docker 容器,我必须部署 war 文件,之后不要执行 docker 提交.
For now if I stop the docker container I have to deploy the war file and don´t do a docker commit after that.
我正在使用在 vagrant 上运行的 ubuntu 12.04
I am using ubuntu 12.04 running on vagrant
我使用主管运行 ssh 和 jboss7.
I use a supervisor to run ssh and jboss7.
我的主管档案:
[supervisord]
nodaemon=true
[program:sshd]
command=/usr/sbin/sshd -D
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
autorestart=true
[program:jboss]
command=/usr/local/share/jboss/bin/./standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
autorestart=true
接下来我的步骤:
vagrant up
[default] Forwarding ports...
[default] -- 10022 => 10022 (adapter 1)
[default] -- 8080 => 18080 (adapter 1)
Jboss-as7 日志:
Jboss-as7 log:
05:00:49,135 INFO [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on /0.0.0.0:4447
05:00:49,155 INFO [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /0.0.0.0:9999
05:00:49,253 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) JBAS015012: Started FileSystemDeploymentService for directory /usr/local/share/jboss/standalone/deployments
05:00:49,646 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
05:00:49,695 ERROR [org.jboss.as.server] (Controller Boot Thread) JBAS015956: Caught exception during boot: java.lang.IllegalStateException: JBAS014647: Could not rename /usr/local/share/jboss/standalone/configuration/standalone_xml_history/current to /usr/local/share/jboss/standalone/configuration/standalone_xml_history/20140107-050049692
at org.jboss.as.controller.persistence.ConfigurationFile.createHistoryDirectory(ConfigurationFile.java:414) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.persistence.ConfigurationFile.successfulBoot(ConfigurationFile.java:273) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.persistence.BackupXmlConfigurationPersister.successfulBoot(BackupXmlConfigurationPersister.java:65) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractControllerService.finishBoot(AbstractControllerService.java:195) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.ServerService.boot(ServerService.java:268) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:155) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]
05:00:49,719 FATAL [org.jboss.as.server] (Controller Boot Thread) JBAS015957: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.
05:00:49,725 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "ROOT.war"
05:00:49,765 INFO [org.jboss.as.osgi] (MSC service thread 1-3) JBAS011942: Stopping OSGi Framework
05:00:49,777 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."ROOT.war": org.jboss.msc.service.StartException in service jboss.deployment.unit."ROOT.war": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc- 1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_24]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_24]
at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]
Caused by: java.lang.IllegalStateException: Container is down
at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:508) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2228) [jboss-msc- 1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:307) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.as.server.deployment.AbstractDeploymentUnitService.start(AbstractDeploymentUnitService.java:77) [jboss-as- server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc- 1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc- 1.0.2.GA.jar:1.0.2.GA]
任何建议表示赞赏.谢谢
Any suggestion is appreciated. Thanks
更新
我上传了一个Dockerfile和一个ROOT.war文件到github的空文件夹中
I uploaded a Dockerfile and a ROOT.war file to github into the empty folder
https://github.com/poseidonjm/docker-files/
Dockerfile
FROM mhamel/jboss7
RUN apt-get update
RUN apt-get install -y supervisor openssh-server
RUN mkdir -p /var/run/sshd
RUN mkdir -p /var/log/supervisor
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN echo 'root:rhemubuntu' | chpasswd
RUN sed -i 's/enable-welcome-root="true"/enable-welcome-root="false"/' /usr/local/share/jboss/standalone/configuration/standalone.xml
CMD ["/usr/bin/supervisord"]
步骤:
构建docker镜像
docker build -t poseidonjm/empty .
运行容器
docker run -d -p 8080:8080 -p 10022:22 poseidonjm/empty
部署 .war 文件
ifconfig
scp -P 10022 ROOT.war [email protected]:/usr/local/share/jboss/standalone/deployments/ROOT.war
user:root
password:rhemubuntu
第一次测试
http://127.0.0.1:18080/
Hello empty project
OK
停止容器
alias dl='docker ps -l -q'
docker stop `dl`
提交更改
docker commit -run='{"Cmd": ["/usr/bin/supervisord"]}' `dl` poseidonjm/empty
再次运行
docker run -d -p 8080:8080 -p 10022:22 poseidonjm/empty
第二次测试
http://127.0.0.1:18080/
Fail
查看 jboss 日志
Check jboss logs
ssh [email protected] -p 10022
vim /usr/local/share/jboss/standalone/log/server.log
推荐答案
不是真正的解决方案,而是一种解决方法:
Not a real solution, but a workaround:
- ssh 输入
supervisorctl stop jboss
mv/usr/local/share/jboss/standalone/configuration/standalone_xml_history/current/usr/local/share/jboss/standalone/configuration/standalone_xml_history/20140116-034913551
(或其他一些时间戳)- 退出 ssh
docker commit -run='{"Cmd": ["/usr/bin/supervisord"]}' `dl` secondversion
- ssh in
supervisorctl stop jboss
mv /usr/local/share/jboss/standalone/configuration/standalone_xml_history/current /usr/local/share/jboss/standalone/configuration/standalone_xml_history/20140116-034913551
(or some other timestamp)- exit the ssh
docker commit -run='{"Cmd": ["/usr/bin/supervisord"]}' `dl` secondversion
如果您启动该映像(第二版),则它可以正常运行.
That image (secondversion) then runs fine if you start it up.
这篇关于docker jboss7 战争提交.服务器启动以不可恢复的方式失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!