[x] 已知问题: 使用registry作为代理缓存时不支持删除
[x] issues: #3853
[x] 代码片段: configure as a pull through cache
[x] 已知问题: 你的国外服务器到国内的网络线路不理想
[x] 解决方案:
[x] 已知问题: 默认缓存168h,也就是7天。修改配置文件中proxy配置块中的ttl 参数调整缓存时间,0 禁用缓存过期。默认单位ns
delete 开启(本项目默认已开启)hub公共空间下的镜像时兼容不添加library的情况此方案来自交流群里大佬提供,通过nginx实现并实测
# 将下面的$http_upgrade $connection_upgrade变量添加到http块中
http {
# 用于支持WebSocket
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name hub.your_domain.com;
# 在docker hub的配置中添加下面的location规则
location ~ ^/v2/([^/]+)/(manifests|blobs)/(.*)$ {
rewrite ^/v2/(.*)$ /v2/library/$1 break;
proxy_pass http://127.0.0.1:51000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
}
location / {
proxy_pass http://127.0.0.1:51000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
}
}
}
tls: failed to verify certificate: x509: certificate signed by unknown authoritydaemon.json 添加 insecure-registries 并填入您的加速域名(非URL)[x] 已知问题: Registry会定期删除旧内容以节省磁盘空间。下面为官方原文解释:
In environments with high churn rates, stale data can build up in the cache. When running as a pull through cache the Registry periodically removes old content to save disk space. Subsequent requests for removed content causes a remote fetch and local re-caching. To ensure best performance and guarantee correctness the Registry cache should be configured to use the
filesystemdriver for storage.
[x] 已知问题: 当我们在配置文件开启了 delete.enabled.true 那么调度程序会自动清理过期的镜像层或未使用的镜像标签
⚠️ 注意:不要通过在UI上查看某个镜像是否被删除来判断调度程序是否已自动执行删除操作。而是查看对应代理服务的容器日志
[x] 解决方案: 目前 registry 的清理效果对于磁盘小的机器并不理想,如果并不希望镜像文件长时间缓存在本地磁盘,建议通过脚本结合系统crontab实现定时清理
#### 9、拉取了一个镜像之后,发现UI界面没有显示?
./registry/data#### 10、开启认证后,配置daemon.json指定了代理地址,可以正常登入,但是docker pull镜像时无法拉取镜像
[x] 已知问题: 因为对于私有镜像仓库,docker客户端对镜像的相关操作,比如pull push支持不友好(历史遗留问题)相关 issues
[x] 解决方案:
.docker/config.json 配置文件(2)通过vi命令打开配置文件,然后手动在auths配置块里面添加官方地址https://index.docker.io/v1/,auth哈希值与你的私有镜像地址的auth保持一致,然后重启docker即可直接通过docker pull拉取了
vi $HOME/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "复制下面私有镜像登入认证的哈希值填到这里"
},
"你的私有镜像地址": {
"auth": "自动生成的认证哈希值"
}
}
}
# 重启 docker
systemctl restart docker
# 拉取镜像
docker pull nginx
#### 11、如何配置才能让数据不保留到磁盘中?
filesystem 使用本地磁盘存储注册表文件Storage driver 存储驱动改为 inmemory,⚠️ 注意:此存储驱动程序不会在运行期间保留数据。这就是为什么它只适合测试。切勿在生产中使用此驱动程序。#### 12、关于Docker Hub免费拉取政策再次变更后的解决方案?
[x] 解决方案: 修改项目中Docker Hub对应的配置文件registry-hub.yml 添加Docker Hub用户,添加后重新启动Docker Registry容器即可!
...
# username 输入docker hub账号,password 输入对应账号密码
proxy:
remoteurl: https://registry-1.docker.io
username:
password:
ttl: 168h