pull image from local repository, if failed will pull from docker hub
usage: docker-pull NAME[:TAG] eg: docker-pull centos:7 docker-pull dc-centos:7
Signed-off-by: Xiao Shenwei xiaoshenwei96@163.com --- sbin/docker-pull | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 sbin/docker-pull
diff --git a/sbin/docker-pull b/sbin/docker-pull new file mode 100755 index 0000000..61ead7e --- /dev/null +++ b/sbin/docker-pull @@ -0,0 +1,31 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. + +. $CCI_SRC/container/defconfig.sh + +load_cci_defaults + +: ${DOCKER_REGISTRY_HOST:="127.0.0.1"} +: ${DOCKER_REGISTRY_PORT:=5001} + +image_name=$1 + +local_repository() +{ + echo "pull image from local repository" + docker pull $DOCKER_REGISTRY_HOST:$DOCKER_REGISTRY_PORT/$image_name +} + +docker_hub() +{ + echo "pull image from docker hub" + docker pull $image_name +} + +main() +{ + local_repository || docker_hub +} + +main