32 lines
619 B
Bash
Executable File
32 lines
619 B
Bash
Executable File
#!/bin/bash
|
|
|
|
image_tag () {
|
|
|
|
local name; local remove; local id
|
|
|
|
# tags an image
|
|
# -i <imagetag or id> <newimagetag>
|
|
|
|
[[ $# -lt 1 ]] && echo "image base name required" && exit
|
|
[[ $1 == "-r" ]] && remove=true && shift 1
|
|
[[ $1 == "-i" ]] && { shift 1; id=$1; } || id=$(image_id $1)
|
|
name=$(image_name "$1")
|
|
[[ ! $id ]] && { echo "no image with id:$id name:$name"; return 1; }
|
|
|
|
if [[ $2 ]];then
|
|
# echo making tag for $2 $(image_name $2)
|
|
docker tag $id $(image_name $2)
|
|
else
|
|
[[ $remove ]] && docker rmi $name || echo to remove an image tag use -r
|
|
fi
|
|
image_tags $id
|
|
}
|
|
|
|
image_delete () {
|
|
docker rmi -f "$@"
|
|
}
|
|
|
|
|
|
|
|
|