docker搭建harbor镜像仓库

  • 环境需求:docker、docker-compose

  • # 新建目录
    mkdir /home/harbor
    cd /home/harbor
    # 下载harbor版本安装包
    wget https://storage.googleapis.com/harbor-releases/release-1.5.0/harbor-offline-installer-v1.5.1.tgz
    # 解压
    tar xvf harbor-offline-installer-v1.5.1.tgz
    
  • 编辑配置文件

    vim /home/harbor/harbor/harbor.cfg
    
    # Configuration file of Harbor
    hostname = 192.168.1.11
    ui_url_protocol = http
    db_password = root
    max_job_workers = 50 
    customize_crt = on
    ssl_cert = /data/cert/server.crt
    ssl_cert_key = /data/cert/server.key
    secretkey_path = /data
    admiral_url = NA
    log_rotate_count = 50
    log_rotate_size = 200M
    harbor_admin_password = devops
    auth_mode = db_auth
    email_identity = 
    email_server = smtp.mydomain.com
    email_server_port = 25
    email_username = [email protected]
    email_password = abc
    email_from = admin 
    email_ssl = false
    email_insecure = false
    auth_mode = db_auth
    ldap_url = ldaps://ldap.mydomain.com
    ldap_basedn = ou=people,dc=mydomain,dc=com
    ldap_uid = uid 
    ldap_scope = 2 
    ldap_timeout = 5
    ldap_verify_cert = true
    ldap_group_basedn = ou=group,dc=mydomain,dc=com
    ldap_group_filter = objectclass=group
    ldap_group_gid = cn
    ldap_group_scope = 2
    self_registration = on
    token_expiration = 30
    project_creation_restriction = everyone
    db_host = mysql
    db_port = 3306
    db_user = root
    redis_url = redis:6379
    clair_db_host = postgres
    clair_db_password = password
    clair_db_port = 5432
    clair_db_username = postgres
    clair_db = postgres
    uaa_endpoint = uaa.mydomain.org
    uaa_clientid = id
    uaa_clientsecret = secret
    uaa_verify_cert = true
    uaa_ca_cert = /path/to/ca.pem
    registry_storage_provider_name = filesystem
    registry_storage_provider_config =
    

    注:可能会出现自定义的harbor_admin_password不生效。

    ## 启动
    ./install.sh
    

    这里出现/usr/bin/python目录找不到的问题,直接重新安装python解决掉。

  • 访问hostname,即192.168.1.20,直接进入页面,使用admin,Harbor12345登录。

  • 解决login失败问题

    #在daemon.json中添加以下参数
    vim /etc/docker/daemon.json 
    
    {
      "registry-mirrors": ["http://hub-mirror.c.163.com"],
      "insecure-registries": ["192.168.1.11"]
    }
    

    注:这里多个键值,中间需要加英文逗号。

  • 重启

    systemctl restart docker
    cd /home/harbor/harbor
    /.install.sh
    
  • 上传镜像步骤

    # 给需要上传的镜像打上tag
    docker tag image_name 192.168.1.11/library/image_name
    docker push 192.168.1.11/library/image_name
    

    注:harbor初始项目目录为/library,上传的目录harbor上必须要有。

    镜像tag分为4部分,hostname/harbor的项目目录/镜像名:版本号

    版本号不加默认为latest

你可能感兴趣的:(docker搭建harbor镜像仓库)