docker - 如何更改从 'Registry' 显示的 'docker info' 值

标签 docker docker-registry docker-machine

当我运行 docker info 时,它会显示这样的信息:

~ $ docker info
Containers: 0
Images: 8
Server Version: 1.9.1
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 9
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.13-boot2docker
Operating System: Boot2Docker 1.9.1 (TCL 6.4.1); master : cef800b - Fri Nov 20 19:33:59 UTC 2015
CPUs: 1
Total Memory: 1.956 GiB
Name: default
ID: CXQT:PB43:QNMD:W5JY:66QM:QRI7:GJUB:X27R:RQ4U:53I2:QVJS:DYKV
Debug mode (server): true
 File Descriptors: 17
 Goroutines: 29
 System Time: 2015-12-15T06:26:35.824197223Z
 EventsListeners: 1
 Init SHA1:
 Init Path: /usr/local/bin/docker
 Docker Root Dir: /mnt/sda1/var/lib/docker
Username: freewind
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox

你可以注意到在底部有一个Registry:

Registry: https://index.docker.io/v1/

我想知道如何更改此值,例如,将其更改为 http://localhost:5000,这样它将始终从 http://localhost:5000 提取图像?


PS:我已经尝试在创建 docker 机器时添加 --engine-registry-mirror http://localhost:5000:

docker-machine create -d virtualbox \
    --engine-registry-mirror http://localhost:5000 default

并且在机器的/mnt/sda1/var/lib/boot2docker/profile中,包含了以下内容:

EXTRA_ARGS='
--label provider=virtualbox
--registry-mirror http://localhost:5000

'

为了让它先从http://localhost:5000拉取图片。但我仍然想知道如何更改全局 Registry 值(显示在 docker info 中)

最佳答案

how to change the global Registry value (shows in docker info)

这似乎已在 registry/config.go#L30-L31 中修复

// IndexServer is the v1 registry server used for user auth + account creation
    IndexServer = DefaultV1Registry + "/v1/"

注意注册服务will first look for v2 endpoint anyway .

func (s *Service) lookupEndpoints(repoName reference.Named) (endpoints []APIEndpoint, err error) {
    endpoints, err = s.lookupV2Endpoints(repoName)

Issue 16974问“为什么直到现在才让镜像支持私有(private) v2 注册表?”

Without going into detail, the main issue here is trust and provenance. Basically, the registry controls the naming, so once you point the daemon at another registry, you can no longer trust the content if layers collide. We avoid these issues by disallowing arbitrary mirroring.

This is a situation we are working on resolving but it will take some effort to appropriately address.

更具体地说,这在 distribution PR 1136 之后, 与 Proxying to other Registries :

A pull-through caching mode exists for the registry, but is restricted from within the docker client to only mirror the official Docker Hub.
This functionality can be expanded when image provenance has been specified and implemented in the distribution project.

目前,您所能做的就是添加 --disable-legacy-registry 以确保只考虑 V2 版本。不过,这不会更改 docker info 输出。

关于docker - 如何更改从 'Registry' 显示的 'docker info' 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34282535/

相关文章:

docker - Kubernetes PullImageError 使用带有私有(private)镜像的 Docker Hub

docker - 如何使用 Docker 注册表 API 提取有关容器的信息?未经授权

docker - 获取官方 Docker 镜像列表

Docker Compose 不更新内容

java - 如何在java中查找非堆空间内存泄漏?

python - Airflow - 没有名为 "airflow.providers"或 "airflow.contrib.providers"的模块

django - docker-machine 容器中缺少本地文件

带有 rsync 的 docker-machine

selenium - Docker 中的 Nightwatch 仅适用于 Phantom

docker - 在新的 Docker 镜像上自动重建 Openshift pod