IBM pSeries  ppc64le 下的registry v2 的安装

1. 首先配置yum源
	cat >/etc/yum.repos.d/docker.repo <<EOF
	[docker]
	name=Docker
	baseurl=http://ftp.unicamp.br/pub/ppc64el/rhel/7_1/docker-ppc64el/
	enabled=1
	gpgcheck=0
	EOF

2. yum -y docker-io docker-registry

3. 为docker-registry配置systemd脚本:

	cat > /usr/lib/systemd/system/docker-registry.service <<EOF
	[Unit]
	Description=Registry server for Docker

	[Service]
	Type=simple
	ExecStart=/bin/registry /etc/registry/config.yml
	Restart=on-failure

	[Install]
	WantedBy=muti-user.target
	EOF

4. 生成字签证书,并拷贝到/etc/docker/certs.d/下
	a.  cd /etc/registry

	b.  cat > crt.sh <<EOF
		#!/bin/bash
		# 生成自签证书脚本

		#common name默认是主机名
		#CN=`hostname`
		CN='docker.repo'
		#证书名
		CrtName='registry'

		mkdir certs;cd certs

		openssl req -x509 -days 3650 -subj "/CN=${CN}/" -nodes -newkey rsa:4096 -sha256 -keyout ${CrtName}.key -out ${CrtName}.crt


		mkdir -p /etc/docker/certs.d/${CN}:5000 && cp ${CrtName}.crt /etc/docker/certs.d/${CN}:5000
		EOF


5. 修改/etc/registry/config.yml,如下:
	version: 0.1
	log:
	  fields:
	    service: registry
	storage:
	    cache:
	        blobdescriptor: inmemory
	    filesystem:
	        rootdirectory: /dockrepo
	http:
	    addr: docker.repo:5000
	    headers:
	        X-Content-Type-Options: [nosniff]
	    secret: f1bdf18afb9c7f8ab3af6a277799b3a4
	    tls:
	        certificate: /etc/registry/certs/registry.crt
	        key: /etc/registry/certs/registry.key
	health:
	  storagedriver:
	    enabled: true
	    interval: 10s
	    threshold: 3

6. 修改/etc/hosts文件,添加一条记录,如下:
	echo '192.168.32.233	docker.repo' >> /etc/hosts

7. 启动docker和docker-registry服务:
	service docker start 
	service docker-registry start

8. 验证测试:
	docker pull docker.repo:5000/busybox(实际没有这个镜像)
	如果提示 Error: image busybox:latest not found,则说明配置成功

9. 客户端(即要拉去或推送镜像的用户)要做的操作:
	a. mkdir -p /etc/docker/certs.d/docker.repo:5000
	b. scp dockrepo@192.168.32.233/tmp/registry.crt  /etc/docker/certs.d/docker.repo:5000/
	c. echo '192.168.32.233	docker.repo' >> /etc/hosts
	d. service docker restart
	
	
10. 编写showrepo.sh脚本,在命令行下,以表格样式显示registry服务器中有哪些镜像:
    #!/bin/bash
    # Date: 2016.05.06
    #以表格的形式是查看自用regsitry镜像库有哪些镜像
    
    crtPath=/etc/docker/certs.d/docker.repo\:5000/registry.crt
    repoAddr='https://docker.repo:5000/v2/'
    
    
    imgList=$(curl -s --cacert ${crtPath} ${repoAddr}_catalog |jq '.repositories'  |sed -e '/\[/d' -e '/\]/d' | xargs)
    imgList=(${imgList//,/})
    
    awk 'BEGIN{printf("%-40s %-50s\n", "  Name", "   Tags")}'
    for imgName in ${imgList[*]};do
        curl -s --cacert ${crtPath} ${repoAddr}${imgName}/tags/list | column -ts'{}[]' | awk -F'("name":)|("tags":)' 'sub(/,/,"",$2){printf("%-  40s %-50s\n",$2,$3)}'
    done