fabric镜像安装脚本分析

时间:2023-12-29 14:47:02
#!/bin/bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
# export VERSION=1.0.-beta
export ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}')
#Set MARCH variable i.e ppc64le,s390x,x86_64,i386
MARCH=`uname -m` dockerFabricPull() {
local FABRIC_TAG=$
for IMAGES in peer orderer couchdb ccenv javaenv kafka tools zookeeper; do
echo "==> FABRIC IMAGE: $IMAGES"
echo
docker pull hyperledger/fabric-$IMAGES:$FABRIC_TAG
docker tag hyperledger/fabric-$IMAGES:$FABRIC_TAG hyperledger/fabric-$IMAGES
done
} dockerCaPull() {
local CA_TAG=$
echo "==> FABRIC CA IMAGE"
echo
docker pull hyperledger/fabric-ca:$CA_TAG
docker tag hyperledger/fabric-ca:$CA_TAG hyperledger/fabric-ca
} : ${CA_TAG:="$MARCH-$VERSION"}
: ${FABRIC_TAG:="$MARCH-$VERSION"} echo "===> Downloading platform binaries"
curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/fabric-binary/${ARCH}-${VERSION}/fabric-binary-${ARCH}-${VERSION}.tar.gz | tar xz echo "===> Pulling fabric Images"
dockerFabricPull ${FABRIC_TAG} echo "===> Pulling fabric ca Image"
dockerCaPull ${CA_TAG}
echo
echo "===> List out hyperledger docker images"
docker images | grep hyperledger*
VERSION:将要安装的fabric的版本
ARCH:取得操作系统类型,例如linux-amd64
MARCH:取得操作系统位数

下载相关的脚本,与镜像本身没有关系
curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/fabric-binary/${ARCH}-${VERSION}/fabric-binary-${ARCH}-${VERSION}.tar.gz | tar xz
调用dockerFabricPull函数下载镜像,镜像包括:
peer orderer couchdb ccenv javaenv kafka tools zookeeper
docker pull hyperledger/fabric-$IMAGES:$FABRIC_TAG
docker tag hyperledger/fabric-$IMAGES:$FABRIC_TAG hyperledger/fabric-$IMAGES

docker pull  镜像名:版本    (pull下载,会从镜像库自动下载镜像到本机)

docker tag   镜像名:版本  镜像名    (tag重命名,如果不给版本号的话,会当作latest版本,后续使用的时候,也不用加版本号了)

调用dockerCaPull函数下载ca镜像。过程同上。
docker images 显示现有的所有镜像