Browse Source

import

master
Vladimir Smagin 2 months ago
commit
36ce969e6a
3 changed files with 59 additions and 0 deletions
  1. +1
    -0
      .gitignore
  2. +34
    -0
      README.md
  3. +24
    -0
      pull_images.sh

+ 1
- 0
.gitignore View File

@ -0,0 +1 @@
images.txt

+ 34
- 0
README.md View File

@ -0,0 +1,34 @@
# Docker hub image puller
New rules of hub says "we delete images if they not pulled for a while blah blah blah" or something like that. Many unpopular opensource projects will be deleted after this rule applied. This script periodically pulls *all* tags of image from docker hub to prevent image deletion.
## Use
Create file with images you want to save.
For example, `images.txt`
```
iam21h/warm-image-operator
iam21h/sbnc
```
Now run script:
```
$:> /pull_images.sh images.txt
Error: No such image: iam21h/warm-image-operator:0.0.1
Pulling iam21h/warm-image-operator:0.0.1
0.0.1: Pulling from iam21h/warm-image-operator
949de0c45264: Already exists
7e9d54341c0e: Already exists
41d0f9b01f20: Pull complete
923def0692b1: Pull complete
ef76ceff3cc3: Pull complete
Digest: sha256:1b1ce307a4813f99209934396b781d5e6225e7d0a966f2c7159e950bab92b3cf
Status: Downloaded newer image for iam21h/warm-image-operator:0.0.1
....
```
Now add it to your crontab to run once a day.

+ 24
- 0
pull_images.sh View File

@ -0,0 +1,24 @@
#!/bin/bash
imagesFile=$1
function getImageTags {
image="$1"
tags=`wget -q https://registry.hub.docker.com/v1/repositories/${image}/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'`
if [ -n "$2" ]
then
tags=` echo "${tags}" | grep "$2" `
fi
echo "${tags}"
}
for image in $(cat ${imagesFile});
do
for tag in $(getImageTags ${image});
do
# remove image from local cache to force pull
docker rmi ${image}:${tag}
docker pull ${image}:${tag}
done;
done;

Loading…
Cancel
Save