Harbor配置-DockerRegistry私有镜像仓库

Harbor简介

HarborVMware公司开源的企业级Docker Registry项目,其目标是帮助用户迅速搭建一个企业级的Docker registry`服务。

它以Docker公司开源的registry为基础,提供了管理UI,基于角色的访问控制(Role Based AccessControl),AD/LDAP集成、以及审计日志(Auditlogging) 等企业用户需求的功能,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源 Docker Distribution

环境准备

  • Ubuntu 14.04
  • Docker and Docker Compose

Docker Compose 安装

1
2
3
4
5
6
7
```shell
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

$ docker-compose --version
docker-compose version 1.22.0, build f46880fe
1
2
3
4
5
6
7
8
9
10
11
12
13

- python

# <a name="9qd2rr"></a>Harbor下载


下载Harbour版本的二进制文件 [https://github.com/vmware/harbor/releases](https://github.com/vmware/harbor/releases)


```shell
wget https://storage.googleapis.com/harbor-releases/release-1.6.0/harbor-offline-installer-v1.6.0.tgz
tar -zxvf harbor-offline-installer-v1.6.0.tgz

官方的链接正常无法下载,感谢戴亚同学帮忙。

下载解压后进入解压的文件夹

Harbor配置

解压后目录下生成 harbor.conf 文件,根据需要修改配置文件。

Harbor启动

1
2
./install.sh

1
2
3
4
5
6
7
8
9
10
11
12
/home/zhangwei# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
136373bd5377 goharbor/harbor-jobservice:v1.6.0 "/harbor/start.sh" 2 days ago Up 2 days harbor-jobservice
e593d2a724de goharbor/nginx-photon:v1.6.0 "nginx -g 'daemon of…" 2 days ago Up 2 days (healthy) 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:1080->80/tcp nginx
f29c2341d237 goharbor/harbor-ui:v1.6.0 "/harbor/start.sh" 2 days ago Up 2 days (healthy) harbor-ui
a03a1bab796f goharbor/harbor-adminserver:v1.6.0 "/harbor/start.sh" 2 days ago Up 2 days (healthy) harbor-adminserver
c11b5b108311 goharbor/redis-photon:v1.6.0 "docker-entrypoint.s…" 2 days ago Up 2 days 6379/tcp redis
6d95f6c0aaf3 goharbor/harbor-db:v1.6.0 "/entrypoint.sh post…" 2 days ago Up 2 days (healthy) 5432/tcp harbor-db
2fa99bb3d06c goharbor/registry-photon:v2.6.2-v1.6.0 "/entrypoint.sh /etc…" 2 days ago Up 2 days (healthy) 5000/tcp registry
da21879d2dd1 goharbor/harbor-log:v1.6.0 "/bin/sh -c /usr/loc…" 2 days ago Up 2 days (healthy) 127.0.0.1:1514->10514/tcp harbor-log


根据需要修改docker-compose.yml 文件的端口

1
2
3
4
5
6
7
8
9
10
11
12
13
proxy:
image: goharbor/nginx-photon:v1.6.0
container_name: nginx
restart: always
volumes:
- ./common/config/nginx:/etc/nginx:z
networks:
- harbor
ports:
- 1080:80
- 443:443
- 4443:4443

Docker私有源配置

基本命令

1
2
3
4
sudo docker run -d -p 5000:5000 --restart=always  --name registry \
-v /home/docker/registry:/var/lib/registry registry:2 # 加入restart=always 跟随docker启动时自启动
# 本地启动后镜像服务器的地址为 localhost:5000

运行后会自动到docker hub 上拉取

1
2
3
4
sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry 2 2e2f252f3c88 4 weeks ago 33.3MB

阅读更多