TYPO3

Check if a Docker tag exists

Currently, the Docker image for the “typo3solr/ext-solr” package is on the “14.0.x-dev” tag. This is a temporary tag, which will disappear soon. I need to watch this because some of my projects depend on the solr Docker image. I could come up every day to the image page at Docker Hub, but I decided to automate it and wrote a script for cron on my macOS. It will check the tag once a day and report if the tag disappears.

bash
#!/usr/bin/env bash

TOKEN=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:typo3solr/ext-solr:pull" | jq -r .token)

HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
  "https://registry-1.docker.io/v2/typo3solr/ext-solr/manifests/14.0.x-dev")

if [ "$HTTP_CODE" -ne 200 ]; then
    osascript -e 'display notification "Docker tag 14.0.x-dev disappeared" with title "Attention!"'
fi

Then a cron job:

code
0 18 * * * /Users/username/bin/check-solr-tags.sh &> /dev/null

Why are there no comments on this blog? Here's why.