shell脚本
#!/bin/bash
image_name=$1
version=$2
echo ${version}
echo 'build......'
docker build -t ${image_name}:${version} .
echo 'build doing.....'
sleep 10
image_id=`sudo docker images | grep ${image_name} | awk -F" " '{print $3}' | head -n 1`
echo ${image_id}
docker tag ${image_id} 192.168.1.111/yiyi/${image_name}:${version}
sleep 10
docker push 192.168.1.111/yiyi/${image_name}:${version}
sleep 10
docker rmi -f ${image_name}:${version}
echo 'sucess......'
Dockerfile文件
FROM openjdk:8-jdk-alpine
MAINTAINER zheng
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#RUN apk add --update font-adobe-100dpi ttf-dejavu fontconfig
ENV APP_NAME="yiyi-admin"
ENV BASE_DIR="/home/app"
ENV VM_OPTS="-Xms256m -Xmx1024m"
ENV VM_EXT_OPTS=""
ENV SPRING_OPTS=""
WORKDIR ${BASE_DIR}
VOLUME ${BASE_DIR}/config
VOLUME ${BASE_DIR}/log
VOLUME ${BASE_DIR}/fonts/chinese
COPY *.jar ${APP_NAME}.jar
EXPOSE 15003
CMD java -jar -Duser.timezone=Asia/Shanghai ${VM_OPTS} ${VM_EXT_OPTS} -Dfile.encoding=utf-8 ${SPRING_OPTS} -DskipTest=true ${APP_NAME}.jar
执行示例
yiyi-admin 参数1(根据实际需求)
23121801 参数2 (根据实际需求)
sh push.sh yiyi-admin 23121801