部署

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 下载地址: 
https://github.com/goharbor/harbor

# 解压
tar zxvf harbor-offline-installer-v2.0.0.tgz

cd harbor
cp harbor.yml.tmpl harbor.yml

# 修改配置
vim harbor.yml
hostname: 192.168.0.16
https: # 先注释https相关配置
harbor_admin_password: Harbor12345

# 准备工作及安装
./prepare
./install.sh

# 安装完成后查看容器状态
(base) chain@ubuntu:~$ docker ps |grep harbor
3e22bc9eac07 goharbor/harbor-jobservice:v2.11.1 "/harbor/entrypoint.…" 6 hours ago Up 6 hours (healthy) harbor-jobservice
37d1e3b72323 goharbor/nginx-photon:v2.11.1 "nginx -g 'daemon of…" 6 hours ago Up 6 hours (healthy) 0.0.0.0:80->8080/tcp, :::80->8080/tcp nginx
5302de5dd558 goharbor/harbor-core:v2.11.1 "/harbor/entrypoint.…" 6 hours ago Up 6 hours (healthy) harbor-core
d610cd9cfab9 goharbor/registry-photon:v2.11.1 "/home/harbor/entryp…" 6 hours ago Up 6 hours (healthy) registry
c08ce600cce7 goharbor/harbor-db:v2.11.1 "/docker-entrypoint.…" 6 hours ago Up 6 hours (healthy) harbor-db
8f3fb0c4a67c goharbor/harbor-registryctl:v2.11.1 "/home/harbor/start.…" 6 hours ago Up 6 hours (healthy) registryctl
57694bbc4568 goharbor/redis-photon:v2.11.1 "redis-server /etc/r…" 6 hours ago Up 6 hours (healthy) redis
4fe63a92fe3c goharbor/harbor-portal:v2.11.1 "nginx -g 'daemon of…" 6 hours ago Up 6 hours (healthy) harbor-portal
ca1ee6ae49b3 goharbor/harbor-log:v2.11.1 "/bin/sh -c /usr/loc…" 6 hours ago Up 6 hours (healthy) 127.0.0.1:1514->10514/tcp harbor-log

访问地址 :192.168.0.16

客户端增加私有仓库地址

1
2
3
4
5
6
7
8
9
10
11
12
[root@master ]# cat /etc/docker/daemon.json 
{
"registry-mirrors": ["https://docker.1panel.dev","https://docker.m.daocloud.io","https://b9pmyelo.mirror.aliyuncs.com","http://dockerhub.aliangedu.cn"],
"exec-opts": ["native.cgroupdriver=systemd"],
"insecure-registries": ["192.168.0.16"] # 增加此行内容
}

# 重启docker服务
systemctl restart docker

# 查看是否生效
docker info

客户端配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 登录私有仓库
docker login 192.168.0.16

[root@master ]# docker login 192.168.0.16
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded


# 推送私有镜像
# 先修改本地镜像tag
[root@master ]# docker tag java-web-demo:1.0 192.168.0.16/library/java-web-demo:1.0

# 推送镜像
[root@master ]# docker push 192.168.0.16/library/java-web-demo:1.0
The push refers to repository [192.168.0.16/library/java-web-demo]
c6bc751fe812: Pushed
9d60b371d1e7: Pushed
ceead5ca823f: Pushed
2353c173a26a: Pushed
071d8bd76517: Pushed
1.0: digest: sha256:5344a25f7429d697496dbff859ef797f30ccbbd181ac620bdb113ea749973401 size: 1371

推送完成即可在web界面library项目下看到镜像