9d6ee35d34
Check if docker images exist before real pulling docker image list and tmp file read/write is much quicker then docker pull: $ time sudo docker pull docker.io/kolla/centos-binary-ceph-mon:2.0.2 > /dev/null real 0m3.418s user 0m0.043s sys 0m0.031s $ cat pull_test.sh sudo docker images | grep -v TAG | awk '{print $1,$2}' | while read -r image tag; do echo ${image}:${tag} >> /tmp/imags.$$ done echo docker.io/kolla/centos-binary-ceph-mon:2.0.2 | while read line; do grep "$line" /tmp/imags.$$ > /dev/null 2>&1 && continue || true echo Pulling container $line sudo docker pull $line > /dev/null done $ time ./pull_test.sh real 0m0.096s user 0m0.070s sys 0m0.044s Change-Id: I35c0209db6462c90fdc4bebe4e8848089dadbf5e Signed-off-by: QiLiang <liangqi1@huawei.com>
16 lines
455 B
Bash
Executable File
16 lines
455 B
Bash
Executable File
#!/bin/bash -e
|
|
set +x
|
|
|
|
sudo docker images | grep -v TAG | awk '{print $1,$2}' | while read -r image tag; do
|
|
echo ${image}:${tag} >> /tmp/imags.$$
|
|
done
|
|
|
|
#Watch all images get pulled.
|
|
kubectl get pods --namespace $1 -o json | \
|
|
jq -r '.items[].spec.containers[].image' | sort -u | while read line; do
|
|
grep "$line" /tmp/imags.$$ > /dev/null 2>&1 && continue || true
|
|
echo Pulling container $line
|
|
sudo docker pull $line > /dev/null
|
|
done
|
|
set -x
|