Pro*_*ter 11 deployment docker docker-registry
我需要使用哪些CLI命令来检查我的私有docker注册表中的映像是否比我服务器上当前运行的映像更新?
例如,我有一个我运行的容器 docker run -d my.domain.com:5000/project1
我想知道它是否已经过时了.
Pro*_*ter 10
布朗尼指着@mbarthelemy和@amuino让我走上正轨.从那以后我能够提出以下bash脚本,其他人可能觉得有用.它只检查注册表上的标记是否与当前正在执行的容器不同.
#!/bin/bash
# ensure running bash
if ! [ -n "$BASH_VERSION" ];then
echo "this is not bash, calling self with bash....";
SCRIPT=$(readlink -f "$0")
/bin/bash $SCRIPT
exit;
fi
REGISTRY="my.registry.com:5000"
REPOSITORY="awesome-project-of-awesomeness"
LATEST="`wget -qO- http://$REGISTRY/v1/repositories/$REPOSITORY/tags`"
LATEST=`echo $LATEST | sed "s/{//g" | sed "s/}//g" | sed "s/\"//g" | cut -d ' ' -f2`
RUNNING=`docker inspect "$REGISTRY/$REPOSITORY" | grep Id | sed "s/\"//g" | sed "s/,//g" | tr -s ' ' | cut -d ' ' -f3`
if [ "$RUNNING" == "$LATEST" ];then
echo "same, do nothing"
else
echo "update!"
echo "$RUNNING != $LATEST"
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17916 次 |
| 最近记录: |