2
【笔记】Harbor 学习笔记
source link: https://loli.fj.cn/2023/07/26/Harbor%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
通过 Docker 部署 VMWare 公司的 Harbor 服务,实现私有 Docker 镜像仓库
- docker
- docker-compose
下载自动安装程序
wget https://github.com/goharbor/harbor/releases/download/v2.8.2/harbor-offline-installer-v2.8.2.tgz
tar -zxvf harbor-offline-installer-v2.8.2.tgz
rm harbor-offline-installer-v2.8.2.tgz
cd harbor
修改配置文件
复制一份配置文件
cp harbor.yml.tmpl harbor.yml
修改配置文件
指定服务器地址
- 指定当前服务器的 IP 地址或域名,不要使用 127.0.0.1,因为 Harbor 会部署在 Docker 容器中
harbor.yml
hostname: 192.168.0.1
去除 HTTPS 支持
- 注释所有 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
设置 Harbor 密码
- 修改密码,默认密码为
Harbor12345
harbor_admin_password: Harbor12345
自动部署 Harbor
./install.sh
- 访问 80 端口进入 Harbor 登陆页面,默认用户名为
admin
,默认密码为Harbor12345
新建镜像仓库
推送镜像到仓库
配置镜像仓库地址
- 如果
/etc/docker/
目录下没有daemon.json
文件就新建
192.168.0.1:80
:Harbor 的地址
/etc/docker/daemon.json
{
"insecure-registries": ["192.168.0.1:80"]
}
重启 Docker 服务
systemctl restart docker
重命名镜像名
- 重命名 docker 镜像名,格式为
Harbor地址/项目名/镜像名:版本
<id>
:镜像 id 或容器名192.168.0.1:80
:Harbor 的地址
docker tag <id> 192.168.0.1:80/demo/demo:v1.0.0
登陆镜像仓库
admin
:Harbor 用户名Harbor12345
:Harbor 密码192.168.0.1:80
:Harbor 的地址
docker login -u admin -p Harbor12345 192.168.0.1:80
docker push 192.168.0.1:80/demo/demo:v1.0.0
登陆镜像仓库
- 如果是公开仓库,则无需登陆
admin
:Harbor 用户名Harbor12345
:Harbor 密码192.168.0.1:80
:Harbor 的地址
docker login -u admin -p Harbor12345 192.168.0.1:80
docker pull 192.168.0.1:80:8083/demo/demo:v1.0.0
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK