Docker 镜像批量打包
docker save $(docker images | grep -v REPOSITORY | awk 'BEGIN{OFS=":";ORS=" "}{print $1,$2}') -o haha.tar
加载镜像
docker load -i haha.tar
Dockerfile 打包
1、创建 Dockerfile
touch Dockefile
2、编写Dockerfile
vim Dockerfile
'''
FROM monidev.midea.com/library/centos:7.3.1611
MAINTAINER wangzy25
#install java
#RUN yum -y install java
ADD ./jdk-7u79-linux-x64.tar.gz /root
#ADD ./ecf.platform.web-0.0.1-SNAPSHOT.jar /apps/svr/
#ADD ./start.sh /apps/svr/
##set environment variable
ENV JAVA_HOME /root/jdk1.7.0_79
ENV CLASSPATH .:$JAVA_HOME/lib:$JRE_HOME/lib
ENV PATH $JAVA_HOME/bin:$PATH
#set charset
ENV LANG "zh_CN.UTF-8"
#inatall app
EXPOSE 80 443 8082
VOLUME ["/apps/logs/","/apps/svr/"]
#start app
CMD echo "start app ..."
#ENTRYPOINT java -jar /apps/svr/ecf.platform.web-0.0.1-SNAPSHOT.jar --server.port=8082 --spring.profiles.active=sit
ENTRYPOINT /apps/svr/start.sh
CMD echo "started app success"
'''
3、启动脚本
'''
#!/bin/sh
source_path='.'
target_path='/apps/svr'
echo $target_path
cd /apps/svr
java -jar ecf.platform.web-0.0.1-SNAPSHOT.jar
#nohup java -jar ecf.platform.web-0.0.1-SNAPSHOT.jar --spring.profiles.active=sit > nohup.out & 2>&1 &
echo "$RUN_NAME started success."
'''
4、创建镜像
docker build -t ecf/ecf.platform.web:v1 .
5、 启动镜像
docker run -d --name ecf.platform.sit -p 8082:8082 -v /apps/projects/sit/ecf.platform.web:/apps/svr -v /apps/logs/sit:/apps/logs 70dc22557af3
6、 查看启动进程
docke ps -a