Docker-检查私有注册表映像版本 [英] Docker - check private registry image version

查看:87
本文介绍了Docker-检查私有注册表映像版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用哪些CLI命令来检查我的私有Docker注册表中的映像是比我服务器上当前正在运行的版本新的版本?

What CLI commands do I need to use in order to check if the image in my private docker registry is a newer version than the one currently running on my server?

例如我有一个使用 docker run -d my.domain.com:5000/project1

运行的容器我想知道它是否已过时。

and I would like to know if it is out-of-date.

推荐答案

Brownie指出了@mbarthelemy和@amuino谁把我在轨道上。由此,我提出了以下bash脚本,其他人可能会觉得有用。它只是检查注册表上的标记是否与当前正在执行的容器不同。

Brownie points to @mbarthelemy and @amuino who put me on track. From that I was able to come up with the following bash script that others may find useful. It just checks if the tag on the registry is different from the currently executing container.

#!/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

这篇关于Docker-检查私有注册表映像版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆