docker私庫harbor的搭建
1、檔案下載
# wget https://storage.googleapis.com/harbor-releases/harbor-online-installer-v1.5.1.tgz
安裝官網參考
https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
2、安裝docker-compose(pip方式)
yum新增源
# yum install epel-release -y
清空yum快取檔案
# yum clean all
安裝python-pip
# yum install python-pip -y
安裝docker-compost
# pip install -U docker-compose
檢視docker-compose版本
# docker-compose -v
修改Harbor的配置檔案
解壓
# tar zxvf harbor-online-installer-v1.5.1.tgz
# vi harbor.cfg
## Configuration file of Harbor # hostname設定訪問地址,可以使用ip、域名,不可以設定為127.0.0.1或localhost hostname = 172.16.1.146 # 訪問協議,預設是http,也可以設定https,如果設定https,則nginx ssl需要設定on ui_url_protocol = http # mysql資料庫root使用者預設密碼root123,實際使用時修改下 db_password = root123 # 是否開啟自注冊,on開啟,off關閉,可以關閉掉。 self_registration = off # 啟動Harbor後,管理員UI登入的密碼,預設是Harbor12345 harbor_admin_password = Harbor12345 #映象同步job數量 max_job_workers= 50 customize_crt = on #https時候使用 ssl_cert = /data/cert/server.crt ssl_cert_key = /data/cert/server.key secretkey_path = /data admiral_url = NA # 郵件設定,傳送重置密碼郵件時使用 email_identity = email_server = smtp.mydomain.com email_server_port = 25 email_username = [email protected] email_password = abc email_from = admin <[email protected]> email_ssl = false # 認證方式,這裡支援多種認證方式,如LADP、本次儲存、資料庫認證。預設是db_auth,mysql資料庫認證 auth_mode = db_auth # LDAP認證時配置項 #ldap_url = ldaps://ldap.mydomain.com #ldap_searchdn = uid=searchuser,ou=people,dc=mydomain,dc=com #ldap_search_pwd = password #ldap_basedn = ou=people,dc=mydomain,dc=com #ldap_filter = (objectClass=person) #ldap_uid = uid #ldap_scope = 3 #ldap_timeout = 5 # Token有效時間,預設30分鐘 token_expiration = 30 # 使用者建立專案許可權控制,預設是everyone(所有人),也可以設定為adminonly(只能管理員) project_creation_restriction = everyone verify_remote_cert = on #日誌數量 log_rotate_count = 50 #單個日誌大小 log_rotate_size = 200M
docker-compost配置修改(視情況修改)
修改頁面埠
# vi docker-compose.yml
proxy: image: vmware/nginx-photon:v1.5.1 container_name: nginx restart: always volumes: - ./common/config/nginx:/etc/nginx:z networks: - harbor ports: #如果需要,可以修改對外埠為 # - 8888:80 - 80:80 - 443:443 - 4443:4443 depends_on: - mysql - registry - ui - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "proxy"
修改common/templates/registry/onfig.yml
# cd common/templates/registry/
# vi config.yml
version: 0.1 log: level: info fields: service: registry storage: cache: layerinfo: inmemory $storage_provider_info maintenance: uploadpurging: enabled: false delete: enabled: true http: addr: :5000 secret: placeholder debug: addr: localhost:5001 auth: token: issuer: harbor-token-issuer #如果需要,可以新增埠8888 #realm: $public_url/service/token rootcertbundle: /etc/registry/root.crt service: harbor-registry notifications: endpoints: - name: harbor disabled: false url: $ui_url/service/notifications timeout: 3000ms threshold: 5 backoff: 1s
修改docker-compose.yml
# vi docker-compose.yml
version: '2' services: log: image: vmware/harbor-log:v1.5.1 container_name: harbor-log restart: always volumes: #harbor日誌目錄 - /var/log/harbor/:/var/log/docker/:z - ./common/config/log/:/etc/logrotate.d/:z ports: - 127.0.0.1:1514:10514 networks: - harbor registry: image: vmware/registry-photon:v2.6.2-v1.5.1 container_name: registry restart: always volumes: #registry儲存目錄 - /data/registry:/storage:z - ./common/config/registry/:/etc/registry/:z networks: - harbor environment: - GODEBUG=netdns=cgo command: ["serve", "/etc/registry/config.yml"] depends_on: - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "registry" mysql: image: vmware/harbor-db:v1.5.1 container_name: harbor-db restart: always volumes: - /data/database:/var/lib/mysql:z networks: - harbor env_file: - ./common/config/db/env depends_on: - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "mysql" adminserver: image: vmware/harbor-adminserver:v1.5.1 container_name: harbor-adminserver env_file: - ./common/config/adminserver/env restart: always volumes: - /data/config/:/etc/adminserver/config/:z - /data/secretkey:/etc/adminserver/key:z - /data/:/data/:z networks: - harbor depends_on: - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "adminserver" ui: image: vmware/harbor-ui:v1.5.1 container_name: harbor-ui env_file: - ./common/config/ui/env restart: always volumes: - ./common/config/ui/app.conf:/etc/ui/app.conf:z - ./common/config/ui/private_key.pem:/etc/ui/private_key.pem:z - ./common/config/ui/certificates/:/etc/ui/certificates/:z - /data/secretkey:/etc/ui/key:z - /data/ca_download/:/etc/ui/ca/:z - /data/psc/:/etc/ui/token/:z networks: - harbor depends_on: - log - adminserver - registry logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "ui" jobservice: image: vmware/harbor-jobservice:v1.5.1 container_name: harbor-jobservice env_file: - ./common/config/jobservice/env restart: always volumes: - /data/job_logs:/var/log/jobs:z - ./common/config/jobservice/config.yml:/etc/jobservice/config.yml:z networks: - harbor depends_on: - redis - ui - adminserver logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "jobservice" redis: image: vmware/redis-photon:v1.5.1 container_name: redis restart: always volumes: - /data/redis:/data networks: - harbor depends_on: - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "redis" proxy: image: vmware/nginx-photon:v1.5.1 container_name: nginx restart: always volumes: - ./common/config/nginx:/etc/nginx:z networks: - harbor ports: #如果需要,可以修改對外埠為 # - 8888:80 - 80:80 - 443:443 - 4443:4443 depends_on: - mysql - registry - ui - log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "proxy" networks: harbor: external: false
安裝
[[email protected] harbor]# sudo ./install.sh --with-clair
# docker-compose ps
客戶端配置修改
免https修改
修改/etc/docker/daemon.json,新增{"insecure-registries":["192.168.100.117"]}
# echo '{"insecure-registries":["192.168.100.117"]}' >> /etc/docker/daemon.json
# systemctl daemon-reload
# systemctl restart docker
參考部落格:
harbor安裝和簡單使用
https://blog.csdn.net/qq_30062125/article/details/82772087
docker私庫harbor的搭建
https://www.cnblogs.com/smilezgy/p/9545553.html