harbor仓库部署

目录

docker-compose安装

Harbor部署

访问测试

设置开机自启

检测:

docker-compose安装

 [root@slave ~]# curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
 [root@slave ~]# file docker-compose-linux-x86_64.octet-stream 
 docker-compose-linux-x86_64.octet-stream: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
 [root@slave ~]# mv docker-compose-linux-x86_64.octet-stream  docker-compose
 [root@slave ~]# cp docker-compose /usr/local/bin/
 [root@slave ~]# ls /usr/local/bin/
 docker-compose
 [root@slave bin]# chmod +x docker-compose 
 #给执行权限并且验证
 [root@slave bin]# docker-compose -v
 Docker Compose version v2.7.0
 [root@slave bin]# 

Harbor部署

 wget https://github.com/goharbor/harbor/releases/download/v2.5.3/harbor-offline-installer-v2.5.3.tgz
 ​
 [root@slave harbor]# ls
 LICENSE  common.sh  harbor.v2.5.3.tar.gz  harbor.yml.tmpl  install.sh  prepare
 [root@slave harbor]# cp harbor.yml.tmpl harbor.yml
 [root@slave harbor]# vi harbor.yml 
 hostname: 192.168.245.131
 这个是访问域名,有域名就用域名
 #https:
   # https port for harbor, default is 443
  # port: 443
   # The path of cert and key files for nginx
   #certificate: /your/certificate/path
   #private_key: /your/private/key/path
 注释掉https,因为没证书
 往下看会有password,这个是admin账户密码,可以改。  
 harbor_admin_password: Harbor12345
 ​
 [root@slave harbor]# ./install.sh
 ---------
 [Step 5]: starting Harbor ...
 [+] Running 10/10
  ⠿ Network harbor_harbor        Created                                                    0.3s
  ⠿ Container harbor-log         Started                                                    0.6s
  ⠿ Container harbor-portal      Started                                                    2.7s
  ⠿ Container registryctl        Started                                                    2.5s
  ⠿ Container registry           Started                                                    2.5s
  ⠿ Container harbor-db          Started                                                    2.7s
  ⠿ Container redis              Started                                                    2.7s
  ⠿ Container harbor-core        Started                                                    3.3s
  ⠿ Container harbor-jobservice  Started                                                    4.3s
  ⠿ Container nginx              Started                                                    4.3s
 ✔ ----Harbor has been installed and started successfully.----
 ​

访问测试

用户名admin,之前有在配置文件中提到password,密码就是那个password后面的内容。

设置开机自启

 root@slave harbor]# vi harbor.sh
 [root@slave harbor]# cat harbor.sh
 #!/bin/bash
 cd /usr/local/harbor/
 ​
 docker-compose start
 ​
 [root@slave harbor]# chmod +x harbor.sh 
 [root@slave harbor]# cp harbor.sh /etc/profile.d/
 [root@slave harbor]# 

检测:

 [root@slave harbor]#  reboot
 [root@slave harbor]# docker ps
 CONTAINER ID   IMAGE                                COMMAND                  CREATED          STATUS                            PORTS                                   NAMES
 96de59b9f9c4   goharbor/harbor-jobservice:v2.5.3    "/harbor/entrypoint.…"   15 minutes ago   Up 4 seconds (health: starting)                                           harbor-jobservice
 80d49f454f88   goharbor/nginx-photon:v2.5.3         "nginx -g 'daemon of…"   15 minutes ago   Up 3 seconds (health: starting)   0.0.0.0:80->8080/tcp, :::80->8080/tcp   nginx
 401eb2c871b1   goharbor/harbor-core:v2.5.3          "/harbor/entrypoint.…"   15 minutes ago   Up 3 seconds (health: starting)                                           harbor-core
 4f621f10abb5   goharbor/harbor-registryctl:v2.5.3   "/home/harbor/start.…"   15 minutes ago   Up 3 seconds (health: starting)                                           registryctl
 4d713ff48b32   goharbor/harbor-portal:v2.5.3        "nginx -g 'daemon of…"   15 minutes ago   Up 3 seconds (health: starting)                                           harbor-portal
 f52539892190   goharbor/harbor-db:v2.5.3            "/docker-entrypoint.…"   15 minutes ago   Up 3 seconds (health: starting)                                           harbor-db
 6a8912f28379   goharbor/redis-photon:v2.5.3         "redis-server /etc/r…"   15 minutes ago   Up 2 seconds (health: starting)                                           redis
 f028e6ed1967   goharbor/registry-photon:v2.5.3      "/home/harbor/entryp…"   15 minutes ago   Up 4 seconds (health: starting)                                           registry
 73e141ab08c8   goharbor/harbor-log:v2.5.3           "/bin/sh -c /usr/loc…"   15 minutes ago   Up 4 seconds (health: starting)   127.0.0.1:1514->10514/tcp               harbor-log

附:三种添加开机启动的方法

 linux 添加开机启动项的三种方法。
 ​
 (1)编辑文件 /etc/rc.local
 ​
 输入命令:vim /etc/rc.local 将出现类似如下的文本片段:
 ​
 #!/bin/sh
 ​
 #
 ​
 # This script will be executed *after* all the other init scripts.
 ​
 # You can put your own initialization stuff in here if you don't
 ​
 # want to do the full Sys V style init stuff.
 ​
 touch /var/lock/subsys/local
 ​
 /etc/init.d/mysqld start #mysql开机启动
 ​
 /etc/init.d/nginx start #nginx开机启动
 ​
 /etc/init.d/php-fpm start #php-fpm开机启动
 ​
 /etc/init.d/memcached start #memcache开机启动
 ​
 #在文件末尾(exit 0之前)加上你开机需要启动的程序或执行的命令即可(执行的程序需要写绝对路径,添加到系统环境变量的除外),如:
 ​
 /usr/local/thttpd/sbin/thttpd  -C /usr/local/thttpd/etc/thttpd.conf
 ​
 (2)自己写一个shell脚本
 ​
 将写好的脚本(.sh文件)放到目录 /etc/profile.d/ 下,系统启动后就会自动执行该目录下的所有shell脚本。
 ​
 (3)通过chkconfig命令设置
 ​
 将启动文件cp到 /etc/init.d/或者/etc/rc.d/init.d/(前者是后者的软连接)下
 ​
 vim 启动文件,文件前面务必添加如下三行代码,否侧会提示chkconfig不支持
 ​
 #!/bin/sh 告诉系统使用的shell,所以的shell脚本都是这样
 ​
 #chkconfig: 35 20 80 分别代表运行级别,启动优先权,关闭优先权,此行代码必须
 ​
 #description: http server(自己随便发挥)//两行都注释掉!!!,此行代码必须
 ​
 chkconfig --add 脚本文件名 操作后就已经添加了
 还有一种
 写service文件,自行百度。

首先修改本地hosts文件

因为这里是在本地做的实验,并没有dns服务器和dns解析记录,想要通过域名登录到harbor会无法成功。

 客户端的daemon.json配置文件和hosts文件
 [root@master ~]# vim /etc/hosts
 192.168.245.131 xuanxuan.cn
 [root@master ~]# vim /etc/docker/daemon.json
 [root@master ~]# cat /etc/docker/daemon.json
 {
                   "insecure-registries": ["xuanxuan.cn"],
 }
 [root@master ~]# systemctl restart docker
 [root@master ~]# docker login xuanxuan.cn 
 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
 [root@master ~]# 
 [root@master ~]# docker tag httpd:v1 xuanxuan.cn/xuanxuan/httpd:v1
 #把上传的镜像标签先改了
 [root@master ~]# docker push xuanxuan.cn/xuanxuan/httpd:v1
 The push refers to repository [xuanxuan.cn/xuanxuan/httpd]
 f200fcd01309: Pushed 
 313a85b5213a: Pushed 
 af3cf1502ecd: Pushed 
 bd30f621044a: Pushing  37.13MB/504.2MB
 bd30f621044a: Pushing  76.56MB/504.2MB
 174f56854903: Pushing  80.83MB/203.9MB
 在上传
 ​

总结一下,其实在有dns的情况下会简单很多,只需要去/etc/docker/daemon.json里添加一段就行。

 

拉取

 [root@master ~]# docker rmi xuanxuan.cn/xuanxuan/httpd:v1 
 Untagged: xuanxuan.cn/xuanxuan/httpd:v1
 Untagged: xuanxuan.cn/xuanxuan/httpd@sha256:112fe2aaf7bc0d83741ff01e56f694f8edfb222d0bfcb190d9ebd2b73ee5f87a
 [root@master ~]# docker pull xuanxuan.cn/xuanxuan/httpd:v1
 v1: Pulling from xuanxuan/httpd
 Digest: sha256:112fe2aaf7bc0d83741ff01e56f694f8edfb222d0bfcb190d9ebd2b73ee5f87a
 Status: Downloaded newer image for xuanxuan.cn/xuanxuan/httpd:v1
 xuanxuan.cn/xuanxuan/httpd:v1
 [root@master ~]# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值