docker搭建私有仓库

Posted fengzi7314

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker搭建私有仓库相关的知识,希望对你有一定的参考价值。

harbor私有仓库

下载harbor包

wget https://storage.googleapis.com/harbor-releases/release-1.4.0/harbor-offline-installer-v1.4.0.tgz

解压包并进入目录

tar -zxvf harbor-offline-installer-v1.4.0.tgz -C /usr/local/
cd /usr/local/harbor

编辑配置文件

vim harbor.cfg 
   hostname = 192.168.254.13             #对外访问地址
   ui_url_protocol = http                #访问方式
   max_job_workers = 3                   #最大处理进程数
   customize_crt = on                    #是否要启动自定义证书,如果ui_url_protocol = http不生效,如果是https才会生效
  harbor_admin_password = Harbor12345 #admin用户的密码

执行文件

[root@master harbor]# ./install.sh
note:容器名字不能有registry这个名字,否则脚本执行失败

浏览器访问http://server_ip

技术图片

 

创建项目

技术图片

 

 创建仓库

技术图片

修改访问地址

[root@master harbor]# vim /etc/docker/daemon.json 

    "registry-mirrors": ["https://l10nt4hq.mirror.aliyuncs.com"],
    "insecure-registries":["192.168.254.13"]

重启docker服务

[root@master harbor]# service docker restart
Redirecting to /bin/systemctl restart docker.service

 

在linux下登录harbor

技术图片

 

 查看现有的镜像

[root@master harbor]# docker images 
REPOSITORY                                                        TAG                 IMAGE ID            CREATED             SIZE
registry.aliyuncs.com/google_containers/kube-proxy                v1.15.3             232b5c793146        3 weeks ago         82.4 MB
registry.aliyuncs.com/google_containers/kube-apiserver            v1.15.3             5eb2d3fc7a44        3 weeks ago         207 MB
registry.aliyuncs.com/google_containers/kube-scheduler            v1.15.3             703f9c69a5d5        3 weeks ago         81.1 MB
registry.aliyuncs.com/google_containers/kube-controller-manager   v1.15.3             e77c31de5547        3 weeks ago         159 MB
docker.io/mariadb                                                 latest              99c1098d5884        4 weeks ago         355 MB
docker.io/mysql                                                   latest              62a9f311b99c        4 weeks ago         445 MB
quay.io/coreos/flannel                                            v0.11.0-amd64       ff281650a721        7 months ago        52.6 MB
registry.aliyuncs.com/google_containers/coredns                   1.3.1               eb516548c180        8 months ago        40.3 MB
registry.aliyuncs.com/google_containers/etcd                      3.3.10              2c4adeb21b4f        9 months ago        258 MB
vmware/clair-photon                                               v2.0.1-v1.4.0       a1df3526fe43        19 months ago       300 MB
vmware/notary-server-photon                                       v0.5.1-v1.4.0       3edfddb8ece2        19 months ago       211 MB
vmware/notary-signer-photon                                       v0.5.1-v1.4.0       cc70a05cdb6a        19 months ago       209 MB
vmware/registry-photon                                            v2.6.2-v1.4.0       8920f621ddd1        19 months ago       198 MB
vmware/nginx-photon                                               v1.4.0              20c8a01ac6ab        19 months ago       135 MB
vmware/harbor-log                                                 v1.4.0              9e818c7a27ab        19 months ago       200 MB
vmware/harbor-jobservice                                          v1.4.0              29c14d91b043        19 months ago       191 MB
vmware/harbor-ui                                                  v1.4.0              6cb4318eda6a        19 months ago       210 MB
vmware/harbor-adminserver                                         v1.4.0              8145970fa013        19 months ago       182 MB
vmware/harbor-db                                                  v1.4.0              c38da34727f0        19 months ago       521 MB
vmware/mariadb-photon                                             v1.4.0              8457013cf6e3        19 months ago       521 MB
vmware/postgresql-photon                                          v1.4.0              59aa61520094        19 months ago       221 MB
vmware/harbor-db-migrator                                         1.4                 7a4d871b612e        20 months ago       1.15 GB
vmware/photon                                                     1.0                 9b411d78ad9e        20 months ago       130 MB
registry.aliyuncs.com/google_containers/pause                     3.1                 da86e6ba6ca1        21 months ago       742 kB

给要上传的包打标签

[root@master harbor]# docker tag docker.io/mysql:latest 192.168.254.13/databases/mysql:v1

上传镜像

[root@master harbor]# docker push 192.168.254.13/databases/mysql:v1
The push refers to a repository [192.168.254.13/databases/mysql]
647229410363: Pushed 
5b96d5043191: Pushed 
79a46f1eb9d0: Pushed 
bdebd19e878f: Pushed 
995fa4bb8afe: Pushed 
bb1ef34119b2: Pushed 
65430c57aee2: Pushed 
1dd5f3e365cf: Pushed 
7f33ce1066af: Pushed 
9f77b78f01a7: Pushed 
f5741d086b76: Pushed 
8fa655db5360: Pushed 
v1: digest: sha256:f0392b61ae096aef93b25f4b88206d774d2de1a7e43a7780a59a0c319c540b79 size: 2828

浏览器查看harbor

技术图片

 

 已经上传成功,ok

 

以上是关于docker搭建私有仓库的主要内容,如果未能解决你的问题,请参考以下文章

搭建docker私有镜像仓库

Docker私有仓库的搭建与使用

docker私有镜像仓库搭建和镜像删除

搭建docker私有仓库

docker私有仓库的搭建

docker搭建私有仓库