有没有办法将.war文件部署到在docker容器内运行的Jboss-as7中
因为我的jboss服务器在docker提交后似乎失败了.
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/Configuration+file+history
现在,如果我停止docker容器,我必须部署war文件,之后不要进行docker commit.
我正在使用ubuntu 12.04在vagrant上运行
我使用主管来运行ssh和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日志:
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]
任何建议表示赞赏.谢谢
更新
我将一个Dockerfile和一个ROOT.war文件上传到github到空文件夹中
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 root@172.17.42.1:/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日志
ssh root@172.17.42.1 -p 10022
vim /usr/local/share/jboss/standalone/log/server.log
> ssh in
> supervisorctl停止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
如果你启动它,那个图像(secondversion)就可以运行了.