Merge pull request #13157 from jtattermusch/docker_faster_pulls

User GCR mirror for pulling docker images
diff --git a/tools/internal_ci/helper_scripts/prepare_build_linux_rc b/tools/internal_ci/helper_scripts/prepare_build_linux_rc
index ea2a17f..8715d6c 100644
--- a/tools/internal_ci/helper_scripts/prepare_build_linux_rc
+++ b/tools/internal_ci/helper_scripts/prepare_build_linux_rc
@@ -22,6 +22,9 @@
 
 # Move docker's storage location to scratch disk so we don't run out of space.
 echo 'DOCKER_OPTS="${DOCKER_OPTS} --graph=/tmpfs/docker"' | sudo tee --append /etc/default/docker
+# Use container registry mirror for pulling docker images (should make downloads faster)
+# See https://cloud.google.com/container-registry/docs/using-dockerhub-mirroring
+echo 'DOCKER_OPTS="${DOCKER_OPTS} --registry-mirror=https://mirror.gcr.io"' | sudo tee --append /etc/default/docker
 sudo service docker restart
 
 # Populate xdg-cache-home to workaround https://github.com/grpc/grpc/issues/11968
diff --git a/tools/run_tests/dockerize/build_and_run_docker.sh b/tools/run_tests/dockerize/build_and_run_docker.sh
index 80aec82..323c2f7 100755
--- a/tools/run_tests/dockerize/build_and_run_docker.sh
+++ b/tools/run_tests/dockerize/build_and_run_docker.sh
@@ -36,13 +36,13 @@
 # Pull the base image to force an update
 if [ "$DOCKER_BASE_IMAGE" != "" ]
 then
-  docker pull $DOCKER_BASE_IMAGE
+  time docker pull $DOCKER_BASE_IMAGE
 fi
 
 if [ "$DOCKERHUB_ORGANIZATION" != "" ]
 then
   DOCKER_IMAGE_NAME=$DOCKERHUB_ORGANIZATION/$DOCKER_IMAGE_NAME
-  docker pull $DOCKER_IMAGE_NAME
+  time docker pull $DOCKER_IMAGE_NAME
 else
   # Make sure docker image has been built. Should be instantaneous if so.
   docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR
diff --git a/tools/run_tests/dockerize/build_docker_and_run_tests.sh b/tools/run_tests/dockerize/build_docker_and_run_tests.sh
index eea00da..06a5dae 100755
--- a/tools/run_tests/dockerize/build_docker_and_run_tests.sh
+++ b/tools/run_tests/dockerize/build_docker_and_run_tests.sh
@@ -40,7 +40,7 @@
 if [ "$DOCKERHUB_ORGANIZATION" != "" ]
 then
   DOCKER_IMAGE_NAME=$DOCKERHUB_ORGANIZATION/$DOCKER_IMAGE_NAME
-  docker pull $DOCKER_IMAGE_NAME
+  time docker pull $DOCKER_IMAGE_NAME
 else
   # Make sure docker image has been built. Should be instantaneous if so.
   docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR
diff --git a/tools/run_tests/dockerize/build_interop_image.sh b/tools/run_tests/dockerize/build_interop_image.sh
index 09e0629..dbc6bde 100755
--- a/tools/run_tests/dockerize/build_interop_image.sh
+++ b/tools/run_tests/dockerize/build_interop_image.sh
@@ -78,7 +78,7 @@
 if [ "$DOCKERHUB_ORGANIZATION" != "" ]
 then
   BASE_IMAGE=$DOCKERHUB_ORGANIZATION/$BASE_IMAGE
-  docker pull $BASE_IMAGE
+  time docker pull $BASE_IMAGE
 else
   # Make sure docker image has been built. Should be instantaneous if so.
   docker build -t $BASE_IMAGE --force-rm=true tools/dockerfile/interoptest/$BASE_NAME || exit $?