下载docker-compose
[root@Raygussie ~]# ls /usr/local/bin/docker-compose
给它设置执行权限
[root@Raygussie ~]# chmod +x /usr/local/bin/docker-compose
解压harbor到指定文件夹里
[root@Raygussie ~]# tar xf harbor-offline-installer-v2.2.0.tgz -C /usr/local/[root@Raygussie ~]# ls /usr/local/bin etc games harbor include lib lib64 libexec sbin share src
修改文件
[root@Raygussie harbor]# vi harbor.yml//将hostname改为自己的ip地址hostname: 192.168.186.130//把https协议加注释# https related config #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//更改密码harbor_admin_password: mfdsg12345//最下面的代理保持默认,保存退出proxy: http_proxy: https_proxy: no_proxy: components:- core- jobservice- trivy
执行安装脚本
[root@Raygussie harbor]# ./install.sh 。。。。。。 Creating network "harbor_harbor" with the default driver Creating harbor-log ... done Creating harbor-portal ... done Creating registry ... done Creating harbor-db ... done Creating redis ... done Creating registryctl ... done Creating harbor-core ... done Creating nginx ... done Creating harbor-jobservice ... done ✔ ----Harbor has been installed and started successfully.----
设置开机自动启动
[root@Raygussie ~]# vi startall.sh #!/bin/bash cd /usr/local/harbor docker-compose stop && docker-compose start
设置执行权限
[root@Raygussie ~]# chmod +x startall.sh [root@Raygussie harbor]# chmod +x /etc/rc.d/rc.local [root@Raygussie harbor]# ll /etc/rc.d/rc.local -rwxr-xr-x. 1 root root 552 Mar 9 18:56 /etc/rc.d/rc.local
编辑/etc/rc.d/rc.local
[root@Raygussie harbor]# vi /etc/rc.d/rc.local #!/bin/bash/bin/bash /usr/local/harbor/startall.sh
进入harbor网站,输入用户名密码
在用户管理里创建用户,填写信息
设置为管理员
在项目里创建项目
在项目里的成员栏里创建用户
登录仓库拉取镜像
//打上标记[root@Raygussie ~]# docker tag apache:0.1 192.168.186.130/mufeng/apache:0.2[root@Raygussie ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE192.168.186.130/mufeng/apache 0.2 8d0ca6286efe 32 hours ago 362MB//上传镜像[root@Raygussie ~]# docker push 192.168.186.130/mufeng/apache:0.2The push refers to repository [192.168.186.130/mufeng/apache] ab2df020f151: Pushed f0e15c2a3878: Pushed 65f83255e0ff: Pushed 4c6995136b03: Pushed c73ac4df4826: Pushed c04d1437198b: Pushed 0.2: digest: sha256:c90b886b2d73dc07a17ea2106ad17454cc0e898e67e86610ee341a8609efc3dd size: 1584
镜像上传成功
删除镜像后,拉取镜像
[root@Raygussie ~]# docker rmi 192.168.186.130/mufeng/apache:0.2Error: No such image: 192.168.186.130/mufeng/apache:0.2[root@Raygussie ~]# docker pull 192.168.186.130/mufeng/apache:0.20.2: Pulling from mufeng/apache Digest: sha256:c90b886b2d73dc07a17ea2106ad17454cc0e898e67e86610ee341a8609efc3dd Status: Downloaded newer image for 192.168.186.130/mufeng/apache:0.2192.168.186.130/mufeng/apache:0.2[root@Raygussie ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE192.168.186.130/mufeng/apache 0.2 8d0ca6286efe 32 hours ago 362MB