创建Web项目的Docker镜像

基于Java,Mongodb,Tomcat的Supplierprofile项目

  • 禁用selinux
    vi etc/selinux/config
    SELINUX=disabled
    SELINUXTYPE=targeted

  • 运行镜像
    docker run -i --privileged=true -v /home/centos:/usr/local/file -d -p 80:8080 --name sp1 centos /bin/bash

  • 进入镜像
docker exec -it 7bd1d90c7d98 /bin/bash
  • 到file路径
cd /usr/local/file
  • 解压mongodb文件
tar -vxf mongodb-linux-x86_64-3.2.0.tgz
  • 新建服务路径
mkdir /usr/local/server
  • 移动mongodb文件
mv mongodb-linux-x86_64-3.2.0 /usr/local/server/mongodb
  • 创建mongodb数据文件
mkdir /usr/local/mongodb
mkdir /usr/local/mongodb/data
touch /usr/local/mongodb/logs
  • 设置开机自启动
echo "/usr/local/server/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data –logpath=/usr/local/mongodb/logs –logappend --auth –port=27017" >> /etc/rc.local
  • 启动mongodb
/usr/local/server/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --fork --logpath=/usr/local/mongodb/logs

[成功日志]
about to fork child process, waiting until server is ready for connections.
forked process: 40
child process started successfully, parent exiting
  • 解压tomcat
tar -vxf apache-tomcat-8.0.30.tar.gz
  • 移动tomcat文件
mv apache-tomcat-8.0.30 /usr/local/server/tomcat
  • 移动supplierprofile.war
cp supplierprofile.war /usr/local/server/tomcat/webapps/
  • 安装Java
yum install java -y
  • 启动tomcat
/usr/local/server/tomcat/bin/startup.sh
docker commit 7bd1d90c7d98 itmaoo/sp
  • 查看镜像
docker images
  • 提交镜像
docker push itmaoo/sp
阅读更多
个人分类: Docker Derby
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭