#!/bin/bash
cid=$1
#检查参数
init(){
if [ $# -eq 0 ];then
echo “args error”
echo “sh $0 CONTAINER_ID”
exit 1
fi
}
#检查参数
check(){
docker ps |egrep $cid >/dev/null 2>&1
if [ $? -ne 0 ];then
echo “check CONTAINER_ID erro”
exit 1
fi
}
#打印挂在目录
printmounts(){
Source=$(docker inspect -f {{".Mounts"}} $cid |awk ‘{print $2}’ )
Destination=$(docker inspect -f {{".Mounts"}} $cid | awk '{print $3}')
echo "CONTAINER_ID:$cid Source:$Source Destination:$Destination"
}
main(){
init $*
check $*
printmounts
}
main $*