一、安装前准备:
配置本地yum源
1).mount -t iso9660 -o loop /dev/cdrom /media/centos
2).vi /etc/yum.repo.d/Centos_localsource.repo
[CentOS7-Localsource] name=CentOS7 baseurl=file:///media/centos enabled=1 gpgcheck=0
2.配置网络yum源
下载163网易的yum源: wget http://mirrors.163.com/.help/CentOS7-Base-163.repo 中科大的yum源: wget http://centos.ustc.edu.cn/CentOS-Base.repo sohu的yum源 wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
3.yum clean all
yum makecache
yum isntall vim net-tools #(支持ifconfig)
(setenforce 0 && systemctl stop firewalld)
二、安装docker和rancher
下载docker的rpm包(https://download.docker.com/linux/centos/7/x86_64/stable/Packages/)
docker-ce-17.06.0.ce-1.el7.centos.x86_64.rpm
安装docker
yum install docker-ce-17.06.0.ce-1.el7.centos.x86_64.rpm
配置docker加速器
vi /etc/docker/daemon.json
{"registry-mirrors": [" 或 {"registry-mirrors": ["https://registry.docker-cn.com"]}
4.systemctl start docker
5.docker pull rancher/server
6.启动rancher server
docker run -d -v /data1/mysql:/var/lib/mysql --name=rancher-server --restart=unless-stopped -p 7070:8080 rancher/server
7.rancher页面配置及rancher-agent安装见http://blog.chinaunix.net/uid-29757900-id-5676591.html
三、安装registry
docker pull registry
运行registry容器
docker run -d --restart=always -p 5000:5000 --name repo -v /var/lib/registry:/var/lib/registry registry
3.修改/etc/docker/daemon.json添加"insecure-registries":["registry:5000"](参考:http://www.cnblogs.com/lin1/p/6207348.html)
{"registry-mirrors": ["https://registry.docker-cn.com"],"insecure-registries":["192.168.206.134:5000"] }
4.重启docker
systemctl restart docker
5.将公有仓库下载docker包上传到私有仓库(http://www.cnblogs.com/fengzheng/p/5168951.html)
#下载mysql镜像 docker pull mysql #重新标记一个本地镜像为私有仓库的版本,这里将本地的mysql latest标记为192.168.206.134:5000/mysql:yang docker tag mysql:latest 192.168.206.134:5000/mysql:yang #将本地镜像推送到本地仓库中 docker push 192.168.206.134:5000/mysql:yang #查看本地仓库中的镜像列表 [root@jeff yum.repos.d]# curl http://localhost:5000/v2/mysql/tags/list {"name":"mysql","tags":["yang"]} #拉取本地仓库中的镜像 docker pull localhost:5000/mysql:yang
6.私有仓库 Registry中的镜像管理
#检查registry上的镜像 for i in `curl -s 127.0.0.1:5000/v2/_catalog | sed‘s/repositories// ; s/[\[\"\:\{\}]*//g ; s/,/ /g ; s/]//g‘` ; do curl -s 127.0.0.1:5000/v2/$i/tags/list|sed‘s/[\{\}\"]//g; s/name://g; s/,tags:/\t/g‘ ; done #删除私有 registry 中的镜像(参考:http://www.cnblogs.com/wjoyxt/p/5855405.html) 1.修改配置/etc/docker/registry/config.yml 2.使用 API GET /v2/<镜像名>/manifests/<tag> 来取得要删除的镜像:Tag所对应的 digest 比如,要删除 mysql:yang 镜像,那么取得 digest 的命令是: curl --header "Accept: application/vnd.docker.distribution.manifest.v2+json" -I -X HEAD http://192.168.206.134:5000/v2/mysql/manifests/yang 3.然后调用 API DELETE /v2/<镜像名>/manifests/<digest> 来删除镜像。比如: [root@jeff yum.repos.d]# curl -X DELETE "http://192.168.206.134:5000/v2/mysql/manifests/sha256:afd334d5f3b4c31155a09110ad7f4728e8b5c8bdf8bca711aed61cf8247dfdec" {"errors":[{"code":"UNSUPPORTED","message":"The operation is unsupported."}]} ----配置文件已改,但是没删除成功。问题待解----
原文地址:http://svsky.blog.51cto.com/10184644/1959406