Docker Registry 配置

安装并配置 Docker Registry

yum -y install docker-distribution
systemctl enable docker-distribution
systemctl start docker-distribution

拷贝之前下载的镜像到 Registry

mkdir /opt/ose/images
cd /opt/ose/images
cp ~/ocp35/ose-images-core-20170728.tar.gz ./
cp ~/ocp35/ose-images-logging_metric-20170728.tar.gz ./
cp ~/ocp35/ose-images-apps-latest_20170728.tar.gz ./
cp ~/ocp35/ose-images-apps-extra-latest_20170728.tar.gz ./

加载所有镜像

for i in `ls *.tar.gz` ; do docker load -i $i; done;
docker images 验证
# docker images
REPOSITORY                                                                     TAG                 IMAGE ID            CREATED             SIZE
registry.access.redhat.com/openshift3/jenkins-2-rhel7                          latest              e637a4bfe7df        3 days ago          667.6 MB
registry.access.redhat.com/openshift3/metrics-hawkular-metrics                 v3.5                b12e45828aad        3 days ago          1.456 GB
registry.access.redhat.com/openshift3/jenkins-1-rhel7                          latest              681ed41cd68c        3 days ago          661.9 MB
registry.access.redhat.com/openshift3/jenkins-slave-nodejs-rhel7               latest              654e0beb7afa        3 days ago          652.5 MB
registry.access.redhat.com/openshift3/jenkins-slave-maven-rhel7                latest              22037c84df0e        3 days ago          578.6 MB
registry.access.redhat.com/openshift3/jenkins-slave-base-rhel7                 latest              fdf570a39451        3 days ago          492.1 MB
registry.access.redhat.com/openshift3/metrics-deployer                         v3.5                6c40d3e740a4        4 days ago          893 MB
registry.access.redhat.com/openshift3/metrics-cassandra                        v3.5                e6ed41b324a4        4 days ago          540.6 MB

推送镜像到本地 Docker Registry

cp /etc/sysconfig/docker /etc/sysconfig/docker.bak.$(date "+%Y%m%d%H%M%S")
sed  -i s/".*OPTIONS=.*"/"OPTIONS='--selinux-enabled --insecure-registry 172.30.0.0\/16 --insecure-registry registry.example.com:5000'"/g /etc/sysconfig/docker
sed -i 's/registry.access.redhat.com/registry.example.com:5000/g' /etc/sysconfig/docker
systemctl restart docker

REDHAT_REG="registry.access.redhat.com"
PRIVATE_REG="registry.example.com:5000"
for i in $(docker images|grep $REDHAT_REG|awk '{print $1":"$2}') ; do docker tag  $i "$PRIVATE_REG$(echo $i|awk -F 'com' {'print $2'})" ; done
for i in `docker images|grep $PRIVATE_REG|awk '{print $1":"$2}'` ; do  docker push $i; done
for i in $(docker images|grep $REDHAT_REG|awk '{print $1":"$2}') ; do docker rmi $i ; done

修改核心镜像为具体版本

打具体版本 tag
docker tag registry.example.com:5000/openshift3/ose:v3.5 registry.example.com:5000/openshift3/ose:v3.5.5.15
docker tag registry.example.com:5000/openshift3/ose-deployer:v3.5 registry.example.com:5000/openshift3/ose-deployer:v3.5.5.15
docker tag registry.example.com:5000/openshift3/ose-sti-builder:v3.5 registry.example.com:5000/openshift3/ose-sti-builder:v3.5.5.15
docker tag registry.example.com:5000/openshift3/ose-docker-builder:v3.5 registry.example.com:5000/openshift3/ose-docker-builder:v3.5.5.15
docker tag registry.example.com:5000/openshift3/ose-pod:v3.5 registry.example.com:5000/openshift3/ose-pod:v3.5.5.15
docker tag registry.example.com:5000/openshift3/ose-keepalived-ipfailover:v3.5 registry.example.com:5000/openshift3/ose-keepalived-ipfailover:v3.5.5.15
docker tag registry.example.com:5000/openshift3/ose-docker-registry:v3.5 registry.example.com:5000/openshift3/ose-docker-registry:v3.5.5.15
docker tag registry.example.com:5000/openshift3/ose-recycler:v3.5 registry.example.com:5000/openshift3/ose-recycler:v3.5.5.15
docker tag registry.example.com:5000/openshift3/registry-console:v3.5 registry.example.com:5000/openshift3/registry-console:v3.5.5.15
删除核心镜像 tag v3.5
docker rmi registry.example.com:5000/openshift3/ose:v3.5
docker rmi registry.example.com:5000/openshift3/ose-haproxy-router:v3.5
docker rmi registry.example.com:5000/openshift3/ose-deployer:v3.5
docker rmi registry.example.com:5000/openshift3/ose-sti-builder:v3.5
docker rmi registry.example.com:5000/openshift3/ose-docker-builder:v3.5
docker rmi registry.example.com:5000/openshift3/ose-pod:v3.5
docker rmi registry.example.com:5000/openshift3/ose-keepalived-ipfailover:v3.5
docker rmi registry.example.com:5000/openshift3/ose-docker-registry:v3.5
docker rmi registry.example.com:5000/openshift3/ose-recycler:v3.5
docker rmi registry.example.com:5000/openshift3/registry-console:v3.5
push 核心镜像 tag v3.5.5.15
docker push registry.example.com:5000/openshift3/ose:v3.5.5.15
docker push registry.example.com:5000/openshift3/ose-haproxy-router:v3.5.5.15
docker push registry.example.com:5000/openshift3/ose-deployer:v3.5.5.15
docker push registry.example.com:5000/openshift3/ose-sti-builder:v3.5.5.15
docker push registry.example.com:5000/openshift3/ose-docker-builder:v3.5.5.15
docker push registry.example.com:5000/openshift3/ose-pod:v3.5.5.15
docker push registry.example.com:5000/openshift3/ose-keepalived-ipfailover:v3.5.5.15
docker push registry.example.com:5000/openshift3/ose-docker-registry:v3.5.5.15
docker push registry.example.com:5000/openshift3/ose-recycler:v3.5.5.15
push registry-console 镜像 tag 3.5
docker push registry.example.com:5000/openshift3/registry-console:3.5

查看所有镜像

docker images | sort

验证能否成功下载镜像 (在所有机器上操作)

docker pull registry.example.com:5000/rhscl/php-56-rhel7

results matching ""

    No results matching ""