使用docker搭建私有仓库harbor

安装docker-compose

[root@C82 ~]# wget -c  https://github.com/docker/compose/releases/download/1.25.5/docker-compose-Linux-x86_64
[root@C82 ~]# mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
[root@C82 ~]# chmod  a+x /usr/local/bin/docker-compose
[root@C82 ~]# docker-compose --version
docker-compose version 1.25.5, build 8a1c60f6

安装harbor

//下载安装harbor并解压
[root@C82 ~]# wget -c https://github.com/goharbor/harbor/releases/download/v2.0.0/harbor-offline-installer-v2.0.0.tgz
[root@C82 ~]# tar xf harbor-offline-installer-v2.0.0.tgz -C /usr/local/

//编写yaml文件
[root@C82 ~]# cd /usr/local/harbor/
[root@C82 harbor]# cp harbor.yml.tmpl harbor.yml

//修改配置文件
[root@C82 harbor]# vim harbor.yml
hostname: 192.168.10.30     #主机名修改为自己的ip地址

# https related config
#https:
  # https port for harbor, default is 443     #因为未做https,所以将https全部注释
  #  port: 443
  # The path of cert and key files for nginx
  #  certificate: /your/certificate/path
  # private_key: /your/private/key/path

harbor_admin_password: yzy123!                 #web界面登录密码

//执行脚本
[root@C82 harbor]# ./install.sh 
[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-portal ... done
Creating redis         ... done
Creating harbor-db     ... done
Creating registryctl   ... done
Creating registry      ... done
Creating harbor-core   ... done
Creating nginx             ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----    //安装成功

使用docker搭建私有仓库harbor_第1张图片
使用docker搭建私有仓库harbor_第2张图片

登录

[root@C82 harbor]# vim /etc/docker/daemon.json
[root@C82 harbor]# cat /etc/docker/daemon.json
[root@C82 harbor]# cat /etc/docker/daemon.json
{
	"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"]
}
{"insecure-registries": ["10.0.0.81:80"]}


##重启服务
[root@C82 ~]# systemctl daemon-reload && systemctl restart docker	//重启服务以后需要再跑一遍脚本,80端口才会启动
[root@C82 harbor]# ./install.sh

##登录
[root@C82 harbor]# docker login 192.168.10.30
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搭建私有仓库harbor_第3张图片
使用docker搭建私有仓库harbor_第4张图片

[root@C82 harbor]# docker tag alpine 192.168.10.30/alpine/alpine:v1
[root@C82 harbor]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED         SIZE
apache                          v0.1      a40ff99a8cf2   25 hours ago    259MB
diligence/php                   v0.1      594019e0f08f   25 hours ago    190MB
php                             v0.1      594019e0f08f   25 hours ago    190MB
diligence/nginx                 v0.1      3cdd1a9cadba   25 hours ago    59MB
nginx                           v0.1      3cdd1a9cadba   25 hours ago    59MB
192.168.10.30/nginx/nginx       0.1       3cdd1a9cadba   25 hours ago    59MB
192.168.10.30/nginx/nginx       v0.1      3cdd1a9cadba   25 hours ago    59MB
192.168.10.30/nginx/nginx       v0.2      3cdd1a9cadba   25 hours ago    59MB
192.168.10.30:80/nginx/nginx    0.1       3cdd1a9cadba   25 hours ago    59MB
diligence/apache                v0.1      3cdd1a9cadba   25 hours ago    59MB
192.168.10.30/alpine/alpine     v1        021b3423115f   3 days ago      5.6MB
alpine                          latest    021b3423115f   3 days ago      5.6MB
deligence/httpd                 v0.1      3dbff4b5db01   5 days ago      688MB
diligence/httpd                 v0.1      3dbff4b5db01   5 days ago      688MB
httpd                           v0.1      3dbff4b5db01   5 days ago      688MB
centos                          latest    300e315adb2f   8 months ago    209MB
goharbor/chartmuseum-photon     v2.0.0    4db8d6aa63e9   15 months ago   127MB
goharbor/redis-photon           v2.0.0    c89ea2e53cc0   15 months ago   72.2MB
goharbor/trivy-adapter-photon   v2.0.0    6122c52b7e48   15 months ago   103MB
goharbor/clair-adapter-photon   v2.0.0    dd2210cb7f53   15 months ago   62MB
goharbor/clair-photon           v2.0.0    f7c7fcc52278   15 months ago   171MB
goharbor/notary-server-photon   v2.0.0    983ac10ed8be   15 months ago   143MB
goharbor/notary-signer-photon   v2.0.0    bee1b6d75e0d   15 months ago   140MB
goharbor/harbor-registryctl     v2.0.0    c53c32d58d04   15 months ago   102MB
goharbor/registry-photon        v2.0.0    afdc1b7ada36   15 months ago   84.5MB
goharbor/nginx-photon           v2.0.0    17892f03e56c   15 months ago   43.6MB
goharbor/harbor-log             v2.0.0    5f8ff08e795c   15 months ago   82MB
goharbor/harbor-jobservice      v2.0.0    c68a2495bf55   15 months ago   116MB
goharbor/harbor-core            v2.0.0    3aa3af64baf8   15 months ago   138MB
goharbor/harbor-portal          v2.0.0    e0b1d3c894c4   15 months ago   52.4MB
goharbor/harbor-db              v2.0.0    5c76f0296cec   15 months ago   154MB
goharbor/prepare                v2.0.0    7266d49995ed   15 months ago   158MB
[root@C82 harbor]# docker push 192.168.10.30/alpine/alpine:v1
The push refers to repository [192.168.10.30/alpine/alpine]
bc276c40b172: Mounted from nginx/nginx 
v1: digest: sha256:be9bdc0ef8e96dbc428dc189b31e2e3b05523d96d12ed627c37aa2936653258c size: 528

这里我新建了一个alpine的项目并上传了镜像
使用docker搭建私有仓库harbor_第5张图片
使用docker搭建私有仓库harbor_第6张图片

你可能感兴趣的:(harbor,docker,harbor)