docker之GLASSFISH部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker之GLASSFISH部署相关的知识,希望对你有一定的参考价值。
以下安装以glassfish4做为部署版本
一、前期准备
1.下载或是获取glassfish4软件
2.解压glassfish
3.启动glassfish ./asadmin start-domain domain1
4.修改管理员密码 ./asadmin change-admin-password ###此处是需要交互模式的,原密码为空
二、创建Dockerfile,内容如下:
FROM centos:7
ADD soft/ /mnt
RUN cp -r /mnt/jdk1.8.0_45 /opt/jdk
RUN cp -r /mnt/glassfish4 /opt/glassfish
RUN cp /mnt/build.sh /opt/build.sh
RUN cp /mnt/start.sh /opt/start.sh
RUN sh /opt/build.sh
三、创建build.sh脚本:
export JAVA_HOME=/opt/jdk
export PATH=$JAVA_HOME/bin:$PATH
mkdir /opt/webapp #####程序发布基础目录
/opt/glassfish/glassfish/bin/asadmin start-domain domain1
echo "AS_ADMIN_PASSWORD=adminadmin">/opt/passwd
/opt/glassfish/glassfish/bin/asadmin --port=4848 --user admin --passwordfile /opt/passwd enable-secure-admin
四、创建start.sh脚本:
export JAVA_HOME=/opt/jdk
export PATH=$JAVA_HOME/bin:$PATH
/opt/glassfish/glassfish/bin/asadmin start-domain domain1
echo "AS_ADMIN_PASSWORD=adminadmin">/opt/passwd
/opt/glassfish/glassfish/bin/asadmin deploydir -u admin -W /opt/passwd /opt/webapp/hello ####此处发布一个测试hello程序
/opt/glassfish/glassfish/bin/asadmin stop-domain domain1
/opt/glassfish/glassfish/bin/asadmin start-domain --verbose=true domain1
五、启动容器:
docker run -d -p 28080:8080 -p 24848:4848 -v /mnt/glassfish/soft/hello:/opt/webapp/hello -v /log/hello/:/opt/glassfish/glassfish/domains/domain1/logs liming/glassfish:4 sh /opt/webapp/hello/start.sh
注: 两个v 参数分别挂载了程序目录与日志目录
start.sh脚本中的部署目录要和启动容器时的挂载目录相同
六、目录结构:
./soft
./soft/jdk1.8.0_45
./soft/hello
./soft/hello/index.jsp
./soft/hello/META-INF
./soft/hello/WEB-INF
./soft/hello/start.sh
./soft/build.sh
./soft/glassfish4
./Dockerfile
以上是关于docker之GLASSFISH部署的主要内容,如果未能解决你的问题,请参考以下文章