简介
很多时候我们不想把我们docker镜像直接暴露出来,那么我们就不能直接上传docker-hub上。所以对于个人或者企业,有一个自己的镜像仓库,也是很重要的。本文主要利用harbor这个插件,来搭建个人仓库
安装
OS:Centos7
docker:19
1、安装docker-compose(前提你的系统安装好python)
pip3 install -U -i https://pypi.tuna.tsinghua.edu.cn/simple docker-compose
2、下载harbor
wget https://github.com/goharbor/harbor/releases/download/v2.0.2/harbor-offline-installer-v2.0.2.tgz
由于国外网速慢的问题,我建议直接用迅雷下载,然后上传到linux上。
3、编辑配置文件
# 解压tar -zxvf harbor-offline-installer-v2.0.2.tgz# 切换cd harbor# 复制配置文件cp harbor.yml.tmpl harbor.yml# 编辑配置文件vi harbor.yml# 修改ip地址hostname: 192.168.19.26# 修改端口http: # port for http, default is 80. If https enabled, this port will redirect to https port port: 8080# 注释掉https访问,如果生产环境,建议还是启用https#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 # 修改admin后台登录密码 harbor_admin_password: 12345
4、安装
./install.sh
5、http访问必须要配置
vi /etc/docker/daemon.json{"insecure-registries" : ["192.168.19.26:8080", "0.0.0.0"]}# Restart Docker Engine.systemctl restart docker# Stop Harbor.docker-compose down -v# Restart Harbor.docker-compose up -d
使用
在浏览器输入你的ip地址+端口号
![2a31d243d8ff636f303671ab42afd34e.png](https://i-blog.csdnimg.cn/blog_migrate/584a776da9d6869a4328e2d793bee9b6.jpeg)
新建项目
![59db6d245de1fa3592cf6a7a5104dae9.png](https://i-blog.csdnimg.cn/blog_migrate/ab7a930938c6552ad88c2d51316f4805.jpeg)
# 登录docker 输入账号、密码 docker login 192.168.19.26:8080# 在远程机器上从Docker Hub下载HelloWorld上传到私有仓库docker pull hello-world# 打标签docker tag hello-world:latest 192.168.19.26:8080/test/hello-world#上传docker push 192.168.19.26:8080/test/hello-world:latest
结果
私有仓库,已经有了我们上传的镜像了。
![6b24cfe8746a56868a6ed20937b4d0a3.png](https://i-blog.csdnimg.cn/blog_migrate/e45890e35061023dab2b0d12a2ec7727.jpeg)
最后希望大家多多评论、关注、点赞、转发,你们的支持,是我更新下去的最大动力。