美文网首页
docker仓库

docker仓库

作者: 我的喵叫初六 | 来源:发表于2019-03-15 00:01 被阅读0次

harbor仓库

有web页面,直观,可进行简单删除、目录管理等操作。

====================================================================================

安装

# yum install -y yum-utils device-mapper-persistent-data lvm2

# yum install epel-release -y

# yum install python-pip -y

# pip --version

# pip install --upgrade pip

# pip install -U -i https://pypi.tuna.tsinghua.edu.cn/simple docker-compose

# docker-compose version

# wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-offline-installer-v1.1.2.tgz

我安装的目录位置是/mdata

# tar -zxvf harbor-offline-installer-v1.1.2.tgz -C /mdata

# cd /mdata/harbor

=====================================================================================================

[harbor]# egrep -v '^#|^$' harbor.cfg

# hostname设置访问地址,可以使用ip、域名,不可以设置为127.0.0.1或localhost

hostname = docker.harbor.com

# 访问协议,默认是http,也可以设置https,如果设置https,则nginx ssl需要设置on

ui_url_protocol = http

# mysql数据库root用户默认密码root123,实际使用时修改下

db_password = root123

max_job_workers = 3

customize_crt = on

ssl_cert = /data/cert/server.crt

ssl_cert_key = /data/cert/server.key

secretkey_path = /mdata/harbor-data

admiral_url = NA

# 邮件设置,发送重置密码邮件时使用

email_identity =

email_server = smtp.mydomain.com

email_server_port = 25

email_username = sample_admin@mydomain.com

email_password = abc

email_from = admin <sample_admin@mydomain.com>

email_ssl = false

# 启动Harbor后,管理员UI登录的密码,默认是Harbor12345

harbor_admin_password = passwd@docker

# 认证方式,这里支持多种认证方式,如LADP、本次存储、数据库认证。默认是db_auth,mysql数据库认证

auth_mode = db_auth

# LDAP认证时配置项

ldap_url = ldaps://ldap.mydomain.com

ldap_basedn = ou=people,dc=mydomain,dc=com

ldap_uid = uid

ldap_scope = 3

ldap_timeout = 5

# 是否开启自注册

self_registration = on

# Token有效时间,默认30分钟

token_expiration = 30

# 用户创建项目权限控制,默认是everyone(所有人),也可以设置为adminonly(只能管理员)

project_creation_restriction = everyone

verify_remote_cert = on

上面的harbor.cfg文件我更改了:

hostname = docker.harbor.com        指定域名

secretkey_path = /mdata/harbor-data    我这里指定所有有关harbor启动后的文件存放位置,这是其中一处,后面的文件中还有需要更改的地方

harbor_admin_password = passwd@docker    这里是修改web登录密码,我第一次更改没有生效,如果不生效可以使用默认密码Harbor12345  用户名admin  ,登录后可以在web管理页面进行更改

=================================================================================================================================

因为harbor默认使用/data目录,如果使用挂载磁盘目录,则需要修改文件docker-compose.yml,需要修改的位置我在后面加了#号

[harbor]# cat docker-compose.yml

version: '2'

services:

  log:

    image: vmware/harbor-log:v1.1.2

    container_name: harbor-log

    restart: always

    volumes:

      - /var/log/harbor/:/var/log/docker/:z

    ports:

      - 127.0.0.1:1514:514

    networks:

      - harbor

  registry:

    image: vmware/registry:2.6.1-photon

    container_name: registry

    restart: always

    volumes:

      - /mdata/harbor-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.1.2

    container_name: harbor-db

    restart: always

    volumes:

      - /mdata/harbor-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.1.2

    container_name: harbor-adminserver

    env_file:

      - ./common/config/adminserver/env

    restart: always

    volumes:

      - /mdata/harbor-data/config/:/etc/adminserver/config/:z        ##############################

      - /mdata/harbor-data/secretkey:/etc/adminserver/key:z          #################################

      - /mdata/harbor-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.1.2

    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

      - /mdata/harbor-data/secretkey:/etc/ui/key:z                      ##################################

      - /mdata/harbor-data/ca_download/:/etc/ui/ca/: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.1.2

    container_name: harbor-jobservice

    env_file:

      - ./common/config/jobservice/env

    restart: always

    volumes:

      - /mdata/harbor-data/job_logs:/var/log/jobs:z                          ################################################

      - ./common/config/jobservice/app.conf:/etc/jobservice/app.conf:z

      - /mdata/harbor-data/secretkey:/etc/jobservice/key:z                #########################################

    networks:

      - harbor

    depends_on:

      - ui

      - adminserver

    logging:

      driver: "syslog"

      options: 

        syslog-address: "tcp://127.0.0.1:1514"

        tag: "jobservice"

  proxy:

    image: vmware/nginx:1.11.5-patched

    container_name: nginx

    restart: always

    volumes:

      - ./common/config/nginx:/etc/nginx:z

    networks:

      - harbor

    ports:

      - 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

==================================================================================================

修改完成后

在harbor目录中执行

./install.sh

[Step 0]: checking installation environment ...

Note: docker version: 18.03.1

Note: docker-compose version: 1.18.0

[Step 1]: loading Harbor images ...

查看镜像

docker images

查看启动

docker ps

修改需要访问主机的hosts文件

IP    docker.harbor.com

访问 docker.harbor.com

登录仓库

docker login docker.harbor.com

仓库停止/启动

docker-compose stop/start

修改文件后的停止启动

docker-compose down

docker-compose up -d

docker仓库默认不允许http访问

vim /etc/docker/daemon.json

{ "insecure-registries":["docker.harbor.com"] }

重启docker

访问时 docker login docker.harbor.com 交互输入用户名密码,直接命令中带用户名密码可能登录失败,登录一次后下次登录无需输入密码

==========================================================================

============================================================================

相关文章

网友评论

      本文标题:docker仓库

      本文链接:https://www.haomeiwen.com/subject/yyacmqtx.html