docker图像的版本增量
我打算用下面的命令build立一个IMAGE,但命令没有执行。 你能告诉我下面的脚本中有什么错误吗?
IMAGE = testimage
ID=$(docker build -t ${IMAGE} . | tail -1 | sed 's/.*Successfully built \(.*\)$/\1/') echo $ID docker tag ${ID} pushdocker/${IMAGE}:${VERSION}
这里pushdocker
是我的Docker中心命名空间
我跟着@aron digulla脚本,现在工作正常。
IMAGE=TestImage VERSION=1.0.0 docker build -t ${IMAGE}:${VERSION} . | tee build.log || exit 1 ID=$(tail -1 build.log | awk '{print $3;}')
我从git获取Git Commit Level并将其作为版本号应用于DOCKER Image。
TAG="$(git log --pretty=oneline -1 | awk '{print $1}' | cut -c 1-7)" echo "LATEST COMMIT NUMBER is $TAG" and then apply $TAG to docker tag command like below docker tag image:latest image:$TAG` below is the output. xyz:latest xyz:7digitcommit number