Docker仓库
八、Docker Registry
1、distribution:由docker官方提供
- 安装registry
# yum install docker-registry
# rpm -ql docker-distribution
/etc/docker-distribution/registry/config.yml #配置文件
/usr/lib/systemd/system/docker-distribution.service #服务脚本
/var/lib/registry #镜像存放目录
# vim /etc/docker-distribution/registry/config.yml
version: 0.1
log:
fields:
service: registry
storage:
cache:
layerinfo: inmemory
filesystem:
rootdirectory: /var/lib/registry #目录
http:
addr: :5000 #端口
# systemctl start docker-distribution.service
# systemctl enable docker-distribution.service
- 修改docker daemon使用HTTP协议
# vim /etc/docker/daemon.json
{
"insecure-registries": ["192.168.100.9:5000"]
}
# systemctl restart docker.service
- 推送docker镜像
# docker tag quay.io/coreos/flannel:v0.11.0-amd64 192.168.100.9:5000/flannel:v0.11.0-amd64
# docker push 192.168.100.9:5000/flannel:v0.11.0-amd64
# ls /var/lib/registry/docker/registry/v2/repositories/
2、harbor:由VMware公司在distribution二次开发
- yum install docker-ce-18.06.0.ce-3.el7 -y #docker-ce源提供
- yum install docker-compose -y #epel源提供
- 硬件:2C4G
下载:https://github.com/goharbor/harbor/releases
~]# wget https://storage.googleapis.com/harbor-releases/release-1.4.0/harbor-offline-installer-v1.4.0.tgz
~]# tar xf harbor-offline-installer-v1.4.0.tgz -C /usr/local/
~]# cd /usr/local/harbor/
harbor]# vim harbor.cfg
hostname = harbor.com
ui_url_protocol = http
max_job_workers = 3 #cpu启动几个进程,小于等于总cpu核心数
customize_crt = on #自定义证书,需要客户端信任
ssl_cert = /data/cert/server.crt
ssl_cert_key = /data/cert/server.key
secretkey_path = /data
admiral_url = NA #管理URL,未定义
harbor_admin_password = Harbor12345 #admin登录密码
harbor]# ./install.sh
访问:http://192.168.100.11/harbor/sign-in,admin/Harbor12345
harbor]# docker-compose pause #暂停服务,注意需要在/usr/local/harbor/目录下执行
harbor]# docker-compose unpause #继续
harbor]# docker-compose stop #停止
harbor]# docker-compose start #启动