首页 > 其他分享 >distribution镜像仓库代理缓存

distribution镜像仓库代理缓存

时间:2024-05-13 12:08:23浏览次数:10  
标签:opt 缓存 auth htpasswd registry io 镜像 distribution docker

本文在《学习distribution》之后,梳理一份基础的用于代理远端仓库的基础配置。

配置需求

  • 镜像地址在远端
  • 定期清理缓存
  • 优先没有任何中间件服务
  • 需要健康检查
  • 需要暴露prometheus指标
  • 优先外部正式的HTTPS证书

配置明细

version:0.1
log:
  level: debug
  fields:
    service: registry
    environment: development
storage:
  filesystem:
    rootdirectory: /opt/registry
  delete:
    enabled: true    
  cache:
    blobdescriptor: inmemory
    blobdescriptorsize: 10000
    # 如果用外部redis,inmemory -> redis ,删除blobdescriptorsize
  maintenance:
    uploadpurging:
      enabled: true
      age: 168h
      interval: 24h
      dryrun: false  
    readonly:
      enabled: false    
# 如果用外部redis      
# redis:
#   addr: redis—ip:redis-port
#   password: pw
#   pool:
#     maxidle: 16
#     maxactive: 64
#     idletimeout: 300s
#   dialtimeout: 10ms
#   readtimeout: 10ms
#   writetimeout: 10ms  
proxy:
  remoteurl: https://registry-1.docker.io
  username: username
  password: password    
  ttl: 48h  
http:
  addr: 80
  host: http://mirror-registry-1.docker.io
  secret: mirror-registry-1.docker.io
  debug:
    addr: 5001
    prometheus:
        enabled: true
        path: /metrics  
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3    
# 需要配置用户认证,否则容器运行时需要配置忽略权限验证
# auth:
#   htpasswd:
#     realm: basic-realm
#     path: /opt/htpasswd

htpaasswd配置密钥

mkdir /opt/auth/htpasswd
docker run \
  --entrypoint htpasswd \
  httpd:2 -Bbn testuser testpassword > /opt/auth/htpasswd

运行服务

docker

docker run -itd -p 80:80 -p 5001:5001 \
 --restart=always --name registry \
 -v /opt/registry:/opt/registry \
 -v /opt/auth/htpasswd:/opt/auth/htpasswd \
 -v /opt/docker/registry/config.yml:/etc/docker/registry/config.yml \
 registry:2 

docker compose

registry:
  restart: always
  image: registry:2
  ports:
    - 80:80
    - 5001:5001
  volumes:
    - /opt/auth/htpasswd:/opt/auth/htpasswd
    - /opt/registry:/opt/registry
    - /opt/docker/registry/config.yml:/etc/docker/registry/config.yml
docker compose up -d

垃圾清理

清理过程中会阻碍上传镜像,理论上作为代理仓库不会有上传情况

docker exec registry /bin/registry garbage-collect /etc/docker/registry/config.yml

指定清理镜像

该步骤需要调用registry的http API
参考链接:
https://distribution.github.io/distribution/spec/api/#deleting-a-layer
https://www.yoyoask.com/?p=2843

镜像加速配置

containerd

# /etc/containerd/config.toml
    [plugins."io.containerd.grpc.v1.cri".registry]
      config_path = "/etc/containerd/certs.d"
      [plugins."io.containerd.grpc.v1.cri".registry.configs]
          [plugins."io.containerd.grpc.v1.cri".registry.configs."mirror-registry-1".auth]
            username = "testuser"
            password = "testpassword"
# /etc/containerd/certs.d/mirror-registry-1/hosts.toml
server = "https://registry-1.docker.io"

[host."https://mirror-registry-1.docker.io"]
  capabilities = ["pull", "resolve"]
  skip_verify = true
systemctl restart containerd

标签:opt,缓存,auth,htpasswd,registry,io,镜像,distribution,docker
From: https://www.cnblogs.com/yulinor/p/18188705

相关文章

  • 学习distribution
    本文致力于学习使用cncf项目distribution,即原dockerregistry官方文档翻译内容比较主观,请勿完全信任。基础了解是什么是一个无状态、高度可扩展的服务器端应用程序,用于存储并允许您分发容器映像和其他内容。Harbor基于此开发。基础使用#运行容器dockerrun-d-p5000:......
  • MyBatis的一级、二级缓存
    一级缓存基于PerpetualCache的HashMap本地缓存,其存储作用域为Session,当Session进行flush或close之后,该Session中的所有Cache就将清空,默认打开一级缓存。二级缓存基于namespace和mapper的作用域起作用的,不是依赖于SQLsession,默认也是采用PerpetualCache,HashMap存储。需要单独......
  • go高并发之路——缓存穿透、缓存雪崩
    缓存击穿、缓存穿透、缓存雪崩是使用Redis的三个经典问题,上篇文章讲了缓存击穿,今天就讲下剩下的两个问题。一、缓存穿透定义:缓存穿透是指查询一个根本不存在的数据,缓存层和DB层都不会命中。这样缓存永远不会生效,这些请求最终都会访问数据库。引起DB的压力瞬间变大,导致服务不可用......
  • 详解Redis持久化(持久化高危漏洞利用与多种对抗方案、RDB、AOF、同步手动持久化、异步
    谨防持久化+未授权访问漏洞入侵服务器CVE编号找不到,CNVD有一个:CNVD-2015-07557(国家信息安全漏洞共享平台漏洞编号)。这是我之前写过的文章,漏洞成因、影响范围、POC与对抗方案有详解:谨防利用Redis未授权访问漏洞入侵服务器RDB(RedisDatabase、全量保存,默认方式)极简概括:通过符......
  • Django性能之道:缓存应用与优化实战
    title:Django性能之道:缓存应用与优化实战date:2024/5/1118:34:22updated:2024/5/1118:34:22categories:后端开发tags:缓存系统Redis优点Memcached优缺点Django缓存数据库优化性能监控安全实践引言在当今的互联网时代,用户对网站和应用程序的性能要求越来......
  • mybatis缓存
    缓存缓存(即cache)的作用是为了减去数据库的压力,提高数据库的性能。缓存实现的原理是从数据库中查询出来的对象在使用完后不销毁,而是存储在内存(缓存)中,当再次需要获取该对象时,直接从内存中获取,不再向数据库执行select语句,减少对数据库的查询次数,提高了数据库的性能。缓存是使用Map......
  • 3-6缓存_文件压缩
    3.6缓存文件压缩永久缓存配置nginx提供proxy_store指令将提供资源的服务器的响应内容缓存到本地,适合缓存网站中几乎不变的内容server{  listen80;  server_name192.168.1.1;  location/{  rootcache;    缓存路径需要手动创建给权限/usr/......
  • 查看apk的缓存文件内容
    #进入超级管理用户adbshellsu#挂载system分区,可写一般情况/system分区是只读的,需要挂载为读写。mount-orw,remount/data#查找新增的缓存文件cd/data/data/com.fxb.learningtablet/cache/web_resource_cache/ls-la#apk应用操作完成后比对新增的文件 #修改文件属性chmo......
  • SciTech-Mathmatics-ProbabilitiesAndStatistics-Distribution-is-all-you-need: 概率
    Distribution-is-all-you-need概率统计到深度学习,四大技术路线图谱,都在这里!https://github.com/graykode/distribution-is-all-you-need自然语言处理路线图:数学基础->语言基础->模型和算法项目作者:Tae-HwanJung,Github:graykode,2019-09-3013:35,选自Github自然......
  • 故障分析 | TCP 缓存超负荷导致的 MySQL 连接中断
    1.背景在执行跑批任务的过程中,应用程序遇到了一个问题:部分任务的数据库连接会突然丢失,导致任务无法完成。从数据库的错误日志中,发现了 Abortedconnection 的信息,这说明客户端和服务器之间的通信被异常中断了。2.分析为了找出问题的原因,我们首先根据经验,分析了可能导致连接被......