cd harbor cp harbor.yml.tmpl harbor.yml #默认是harbor.yml.tmpl需要将这个文件重命名一下 vi harbor.yml
如果没有域名,使用IP去访问,需要修改以下几项内容
hostname: 修改成自建服务器IP
http.
port: 端口
注释掉https相关配置项
harbor_admin_password: harbor登陆密码
# Configuration file of Harbor
# The IP address or hostname to access admin UI and registry service. # DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients. hostname: 94.191.122.37 #需要修改成自己的域名,如果没有域名直接填写自己的 IP
# http related config http: # port for http, default is 80. If https enabled, this port will redirect to https port port: 80 #默认端口是80,如果想修改也可以修改成启动端口
# https related config #https: #启用https, 如果不想要,需要注释掉 # https port for harbor, default is 443 #port: 443 #https的端口,默认是443 #The path of cert and key files for nginx #certificate: /your/certificate/path #需要将证书上传到对应路径下,根据情况可自行修改 #private_key: /your/private/key/path #需要将证书上传到对应路径下,根据情况可自行修改
# # Uncomment following will enable tls communication between all harbor components # internal_tls: # # set enabled to true means internal tls is enabled # enabled: true # # put your cert and key files on dir # dir: /etc/harbor/tls/internal
# Uncomment external_url if you want to enable external proxy # And when it enabled the hostname will no longer used # external_url: https://reg.mydomain.com:8433
# The initial password of Harbor admin # It only works in first time to install harbor # Remember Change the admin password from UI after launching Harbor. harbor_admin_password: xxxxxx密码 #登陆镜像仓库的初始化密码,根据情况可自行修改
# Harbor DB configuration database: # The password for the root user of Harbor DB. Change this before any production use. password: xxxxxxx密码 # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained. max_idle_conns: 50 # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections. # Note: the default number of connections is 1024 for postgres of harbor. max_open_conns: 1000
# The default data volume data_volume: /data #默认是/data 根据情况自行修改,如果是生产环境使用,建议是修改下镜像存储的路径
###################下面其他内容保持默认就可以,这里就不累赘介绍了
修改完配置后,确认无误执行如下命令进行安装
./install.sh
[Step 5]: starting Harbor ... [+] Running 10/10 ⠿ Network harbor_harbor Created 0.0s ⠿ Container harbor-log Started 0.9s ⠿ Container redis Started 1.7s ⠿ Container harbor-portal Started 1.8s ⠿ Container registryctl Started 1.5s ⠿ Container harbor-db Started 1.6s ⠿ Container registry Started 1.8s ⠿ Container harbor-core Started 2.2s ⠿ Container nginx Started 2.9s ⠿ Container harbor-jobservice Started 2.9s ✔ ----Harbor has been installed and started successfully.----
#1,登陆 [root@VM-249-124-tlinux ~/harbor]# docker login 94.191.122.37 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, #2,从dockerhub下载一个测试镜像 [root@VM-249-124-tlinux ~/harbor]# docker pull busybox Using default tag: latest latest: Pulling from library/busybox 2c39bef88607: Pull complete Digest: sha256:20142e89dab967c01765b0aea3be4cec3a5957cc330f061e5503ef6168ae6613 Status: Downloaded newer image for busybox:latest docker.io/library/busybox:latest [root@VM-249-124-tlinux ~/harbor]# docker images | grep busy busybox latest c98db043bed9 3 days ago 1.24MB #3,重新打tag [root@VM-249-124-tlinux ~/harbor]# docker tag c98db043bed9 94.191.122.37/docker/busybox:harbor
#4,推送到自建的镜像仓库,需要主要的是项目需要添加创建好,我这里创建的是docker项目 [root@VM-249-124-tlinux ~/harbor]# docker push 94.191.122.37/docker/busybox:harbor The push refers to repository [94.191.122.37/docker/busybox] c1cf1676e7d0: Pushed harbor: digest: sha256:15a3c8a1b44b5ef66f9b4b2e1875b50302d100e116f1d4d5ede71d5ac63177c3 size: 527
# The IP address or hostname to access admin UI and registry service. # DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients. hostname: harbor.chen1900s.com
# http related config http: # port for http, default is 80. If https enabled, this port will redirect to https port port: 80
# https related config https: # https port for harbor, default is 443 port: 443 # The path of cert and key files for nginx certificate: /root/ssl/harbor.chen1900s.com.crt private_key: /root/ssl/harbor.chen1900s.com.key
# # Uncomment following will enable tls communication between all harbor components # internal_tls: # # set enabled to true means internal tls is enabled # enabled: true # # put your cert and key files on dir # dir: /etc/harbor/tls/internal #######其他配置保持不变
2,执行安装命令
./prepare
./install.sh
[Step 5]: starting Harbor ... [+] Running 9/9 ⠿ Container harbor-log Started 0.7s ⠿ Container harbor-portal Started 1.7s ⠿ Container harbor-db Started 1.5s ⠿ Container registry Started 1.6s ⠿ Container redis Started 1.7s ⠿ Container registryctl Started 1.5s ⠿ Container harbor-core Started 2.0s ⠿ Container nginx Started 2.6s ⠿ Container harbor-jobservice Started 2.6s ✔ ----Harbor has been installed and started successfully.----
systemctl daemon-reload 重新加载daemon systemctl restart docker #重启docker服务 systemctl status docker
docker-compose restart #登陆harbor配置目录执行
登陆和上传拉取镜像
登陆:
root@VM-249-124-tlinux ~/harbor]# docker login harbor.chen1900s.com 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
上传镜像:
docker tag 80d28bedfe5d harbor.chen1900s.com/library/pause:latest #将镜像重新打tag docker push harbor.chen1900s.com/library/pause:latest #推送镜像 The push refers to repository [harbor.chen1900s.com/library/pause] ba0dae6243cc: Pushed latest: digest: sha256:4a1c4b21597c1b4415bdbecb28a3296c6b5e23ca4f9feeb599860a1dac6a0108 size: 52
登陆其他节点拉取镜像
[root@VM-0-33-tlinux ~]# docker pull harbor.chen1900s.com/library/pause:latest latest: Pulling from library/pause Digest: sha256:4a1c4b21597c1b4415bdbecb28a3296c6b5e23ca4f9feeb599860a1dac6a0108 Status: Downloaded newer image for harbor.chen1900s.com/library/pause:latest harbor.chen1900s.com/library/pause:latest