运维-docker-harbor

158 阅读1分钟

前置条件

  1. harbor需要docker compose工具进行启动
  2. 高版本的docker已经包含docker compose(可通过docker compose version命令查看)
  3. github搜索harbor下载离线文件

image.png

image.png

步骤1

创建文件并且导入harbor的离线安装包文件,并且解压

mkdir /opt/harbor

cd /opt/harbor

tar xf harbor-offline-installer-v2.11.0.tgz

步骤2

修改配置文件

cd /harbor

vim harbor.yml.tmpl 

1 修改hostname为当前主机IP如下

# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 192.168.255.130

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 80

2 注释掉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
  # enable strong ssl ciphers (default: false)
  # strong_ssl_ciphers: false



然后
cp harbor.yml.tmpl harbor.yml

步骤3

准备 && 安装

注意:需要把docker容器里面的nginx和httpd关闭,80端口不可被占用。

./prepare

./install.sh

步骤4

在浏览器打开docker主机的ip地址,根据harbor.yml里面的账号密码登录

image.png

image.png

image.png

步骤5

设置docker的源然后重启。根据harbor给到的提示命令推送镜像上去

image.png

image.png

  1. 生成对应镜像
  2. 登录
  3. 推送
docker tag centos:centos7-nginx 192.168.255.130/library/centos7:nginx

docker login http://192.168.255.130

docker push 192.168.255.130/library/centos7:nginx 

image.png

步骤6 验证

删除docker本地的镜像,然后再重新从harbor中拉取

docker rmi 192.168.255.130/library/centos7:nginx 

docker pull 192.168.255.130/library/centos7:nginx