建立Web專案的Docker映象
阿新 • • 發佈:2018-12-26
基於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