35 lines
651 B
Bash
Executable File
35 lines
651 B
Bash
Executable File
#!/bin/bash
|
|
|
|
image_tag () {
|
|
|
|
local DIR
|
|
DIR=$(cd "$(dirname "$BASH_SOURCE")" >/dev/null 2>&1 ; pwd -P )
|
|
|
|
# tags an image
|
|
# -d -f <imagetag or id> <newimagetag>
|
|
|
|
[[ $# -lt 1 ]] && echo "image base name required" && exit
|
|
|
|
|
|
[[ $1 == "-d" ]] && delete=true && shift 1
|
|
[[ $1 == "-f" ]] && force=true && shift 1
|
|
[[ $1 == "-i" ]] && { shift 1; id=$1; } || id=$(image_id $1)
|
|
|
|
[[ ! $id ]] && { echo "no image with id $id $(make_tag "@")"; return 1; }
|
|
|
|
|
|
[[ $force ]] && docker rmi -f $id && return 0
|
|
|
|
if [[ $delete ]];then
|
|
docker rmi $id
|
|
else
|
|
docker tag $id $(make_tag $2)
|
|
fi
|
|
echo tags after operation for image $id
|
|
image_info -k RepoTags $id
|
|
}
|
|
|
|
|
|
|
|
|