Reputation: 2942
I'm running Jenkins from Docker with tag lts
. behind this tag was version 2.73.2
. Now there is a newer lts
version available: 2.73.3
. Docker doesn't automatically check for it. I had to do docker pull jenkins/jenkins:lts
to get the new version.
But how can check if there is a newer build for a tag?
EDIT: I want to make clear: This is not a duplicate! I asked how to check for a newer Docker image available. I know how to upgrade (as I said above).
Upvotes: 6
Views: 12074
Reputation: 1333
If using docker hub, you can do something like this:
REPOSITORY=XXX
TAG=latest
TOKEN=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:$REPOSITORY:pull" | /usr/bin/env python -c 'import sys, json; print(json.load(sys.stdin)["token"])')
TARGET_DIGEST=$(curl -s -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.docker.distribution.manifest.v2+json" https://index.docker.io/v2/$REPOSITORY/manifests/$TAG | /usr/bin/env python -c 'import sys, json; print(json.load(sys.stdin)["config"]["digest"])')
if docker images --no-trunc --format "{{.ID}}" $REPOSITORY | grep "$TARGET_DIGEST"; then
echo "$REPOSITORY:$TAG up to date"
else
echo "WARNING: $REPOSITORY:$TAG is out of date"
echo "remote digest $TARGET_DIGEST"
fi
Upvotes: 0
Reputation: 432
There is a project called Watchtower (https://github.com/v2tec/watchtower), which watches the running container and if there is a new version with the same tag available, it will pull the new image and restart the container.
Upvotes: 5
Reputation: 51768
Docker does not check for newer version of remote image. When building, Docker first check to see if the base image is in the local cache. If it find it is uses it, otherwise it tries to pull it from the remote repository.
I order to get latest image, you have to do it manually by running:
docker pull jenkins/jenkins:lts
Alternatively, you can disable the cache when building and always download the latest image by specifying the --no-cache option:
docker build --no-cache ...
Upvotes: 0