docker-registry-web

摘录自:https://github.com/mkuchin/docker-registry-web

Web UI, authentication service and event recorder for private docker registry v2.

Docker Stars Docker Pulls

Features:

  • Browsing repositories, tags and images in docker registry v2
  • Optional token based authentication provider with role-based permissions
  • Docker registry notification recording and audit

Warning: this version config is not compatible with configuration of versions prior 0.1.0

Migrating configuration from 0.0.4 to 0.1.x

Docker pull command

docker pull hyper/docker-registry-web

How to run

Quick start (config with environment variables, no authentication)

Do not use registry as registry container name, it will break REGISTRY_NAME environment variable.

docker run -d -p 5000:5000 --name registry-srv registry:2
docker run -it -p 8080:8080 --name registry-web --link registry-srv -e REGISTRY_URL=http://registry-srv:5000/v2 -e REGISTRY_NAME=localhost:5000 hyper/docker-registry-web 
Connecting to docker registry with basic authentication and self-signed certificate
docker run -it -p 8080:8080 --name registry-web --link registry-srv \
           -e REGISTRY_URL=https://registry-srv:5000/v2 \
           -e REGISTRY_TRUST_ANY_SSL=true \
           -e REGISTRY_BASIC_AUTH="YWRtaW46Y2hhbmdlbWU=" \
           -e REGISTRY_NAME=localhost:5000 hyper/docker-registry-web
No authentication, with config file
  1. Create configuration file config.yml

    (Any property in this config may be overridden with environment variable, for example property registry.auth.enabledwill become REGISTRY_AUTH_ENABLED)

    registry:
      # Docker registry url
      url: http://registry-srv:5000/v2
      # Docker registry fqdn
      name: localhost:5000
      # To allow image delete, should be false
      readonly: false
      auth:
        # Disable authentication
        enabled: false
    
  2. Run with docker

    docker run -p 5000:5000 --name registry-srv -d registry:2
    docker run -it -p 8080:8080 --name registry-web --link registry-srv -v $(pwd)/config.yml:/conf/config.yml:ro hyper/docker-registry-web
    
  3. Web UI will be available on http://localhost:8080

With authentication enabled

Token authentication requires RSA private key in PEM format and certificate matched with this key

  1. Generate private key and certificate

    mkdir conf
    openssl req -new -newkey rsa:4096 -days 365 -subj "/CN=localhost" \
            -nodes -x509 -keyout conf/auth.key -out conf/auth.cert
    
  2. Create registry config conf/registry-srv.yml

    version: 0.1    
    
    storage:
      filesystem:
        rootdirectory: /var/lib/registry
        
    http:
      addr: 0.0.0.0:5000   
        
    auth:
      token:
        # external url to docker-web authentication endpoint
        realm: http://localhost:8080/api/auth
        # should be same as registry.name of registry-web
        service: localhost:5000
        # should be same as registry.auth.issuer of registry-web
        issuer: 'my issuer'
        # path to auth certificate
        rootcertbundle: /etc/docker/registry/auth.cert
    
  3. Start docker registry

    docker run -v $(pwd)/conf/registry-srv.yml:/etc/docker/registry/config.yml:ro \
                -v $(pwd)/conf/auth.cert:/etc/docker/registry/auth.cert:ro -p 5000:5000  --name registry-srv -d registry:2    
    
  4. Create configuration file conf/registry-web.yml

    registry:
      # Docker registry url
      url: http://registry-srv:5000/v2
      # Docker registry fqdn
      name: localhost:5000
      # To allow image delete, should be false
      readonly: false
      auth:
        # Enable authentication
        enabled: true
        # Token issuer
        # should equals to auth.token.issuer of docker registry
        issuer: 'my issuer'
        # Private key for token signing
        # certificate used on auth.token.rootcertbundle should signed by this key
        key: /conf/auth.key
    
  5. Start registry-web

    docker run -v $(pwd)/conf/registry-web.yml:/conf/config.yml:ro \
               -v $(pwd)/conf/auth.key:/conf/auth.key -v $(pwd)/db:/data \
               -it -p 8080:8080 --link registry-srv --name registry-web hyper/docker-registry-web
    
  6. Web UI will be available on http://localhost:8080 with default admin user/password admin/admin.

Role system

After first start you will have following roles:

  • UI_ADMIN
  • UI_USER
  • UI_DELETE
  • read-all
  • write-all

You can't delete or modify UI_ADMIN and UI_USER role, they are special roles and allows admin or user access to UI respectively.
User access allows to browse registry, admin access allows to create, delete and modify users and roles in addition to user access.

UI_DELETE role allows deleting images in the UI based on ACLs.

Every non-special role has a list of ACLs, each of ACL grants permission grants permission to pullpull+push or pull+push+delete based on IP and image name glob matching. For example read-all role matches any IP and any image name with glob * and grants pull permission and write-all role grants pull+push permission for any IP and any image name.

Configuration reference

Docker Compose configuration examples


Migrating configuration from 0.0.4 to 0.1.x

config option in 0.0.4config option in 0.1.xComment
REGISTRY_HOSTREGISTRY_URLURL should start with protocol, e.g. https://registry-srv:5000/v2
REGISTRY_PORT
REGISTRY_NAMEREGISTRY_NAMEvisible name of registry
REGISTRY_AUTHREGISTRY_BASIC_AUTHBase64 encoded authentication string, e.g. YWRtaW46Y2hhbmdlbWU=
READONLYREGISTRY_READONLYtrue|false
TRUST_ANY_SSLREGISTRY_TRUST_ANY_SSLtrue|false
CONTEXT_PATHREGISTRY_CONTEXT_PATHurl prefix if you need to host web registry on non-root path
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是搭建私服镜像中心docker-registrydocker-registry-web的步骤: 1.安装DockerDocker Compose 2.创建一个目录来存储docker-compose.yml文件和证书文件 3.创建docker-compose.yml文件并添加以下内容: ```yaml version: '3' services: registry: restart: always image: registry:2 ports: - 5000:5000 environment: REGISTRY_AUTH: htpasswd REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm REGISTRY_STORAGE_DELETE_ENABLED: "true" REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt REGISTRY_HTTP_TLS_KEY: /certs/domain.key volumes: - ./data:/var/lib/registry - ./auth:/auth - ./certs:/certs registry-web: restart: always image: mkuchin/docker-registry-web:v0.1.2 ports: - 8080:8080 environment: REGISTRY_URL: https://registry:5000 REGISTRY_WEB_TITLE: Docker Registry REGISTRY_AUTH: htpasswd REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt REGISTRY_HTTP_TLS_KEY: /certs/domain.key volumes: - ./auth:/auth - ./certs:/certs ``` 4.创建一个目录来存储证书文件和htpasswd文件 5.生成证书文件 ```shell openssl req -newkey rsa:4096 -nodes -sha256 -keyout domain.key -x509 -days 365 -out domain.crt ``` 6.生成htpasswd文件 ```shell htpasswd -Bc auth/htpasswd <username> ``` 7.启动docker-compose ```shell docker-compose up -d ``` 8.访问https://<your-domain>:8080,输入用户名和密码即可登录docker-registry-web界面。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值