一、docker-distribution
- 安装docker-distribution软件
1
| yum install docker-distribution
|
- 配置registry/config.yml文件
1 2 3 4 5 6 7 8 9 10 11 12
| # /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
|
- 启动docker-distribution服务
1 2
| systemctl start docker-distribution systemctl enable docker-distribution
|
运维
二、运行容器registry
直接运行docker run
1 2
| docker run -d -p 5000:5000 -v /data/registry:/var/lib/registry --name registry --r estart=always registry
|
Docker安装镜像仓库的三种方法
三、搭建Harbor
Harbor部署在主机上
部署相关资料地址:Harbor 地址
下载offline部署文件:Harbor offline installer
部署手册:Harbor部署手册
- 安装必要软件
1
| yum install docker-1.12.6 docker-compose -y
|
- 在 /etc/hosts 添加harbor地址
1 2
| # /etc/hosts 192.168.2.3 harbor.openshift
|
- 在 harbor/harbor.cfg 修改hostname
1 2
| # harbor/harbor.cfg hostname = harbor.openshift:1080
|
Harbor默认镜像存储在 /data/ 目录下
4. 更新Harbor对外服务端口号
1 2 3 4 5 6
| # harbor/docker-compose.yml 123行 - 1080:80 - 1443:443 - 4443:4443 # harbor/harbor.cfg hostname = harbor.openshift:1080
|
- 启动docker
1 2 3 4 5 6 7
| # 执行之前请确认/var/lib/docker文件夹是否单独挂盘 # 更新 /etc/sysconfig/docker 配置 # 添加 OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry=0.0.0.0/0 --registry-mirror=https://docker.mirrors.ustc.ed u.cn' systemctl start docker
|
- 安装Harbor
- 测试Harbor
1
| docker login harbor.openshift
|
- 维护Harbor
a. 暂停
b. 暂停后重新启动
c. 更新harbor.cfg后启动
1 2 3
| docker-compose down -v ./prepare docker-compose up -d
|
d. 删除Harbor
1 2 3
| docker-compose down -v rm -r /data/database rm -r /data/registry
|