now=$(date +%Y%m%d) if [ $# -eq 0 ]; then echo "镜像名称" exit 1 fi tag=$0 if [ $# -eq 1 ]; then echo "请输入版本号" exit 1 fi version=$1 if [ $# -eq 2 ]; then echo "请输入版本号" filePath=$2 else filePath=Dockerfile fi docker build -t $tag:$version-$now -f $filePath .