最近做个项目,创建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
宿主机器浏览URL,确认成功
http://127.0.0.1/supplierprofile/profile.rpc
生成镜像
docker commit 7bd1d90c7d98 itmaoo/sp
查看镜像
docker images
提交镜像
docker push itmaoo/sp
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!