[go: up one dir, main page]

registry

package
v2.0.0-beta.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package registry contains client primitives to interact with a remote Docker registry.

Index

Constants

View Source
const (
	// DefaultNamespace is the default namespace
	DefaultNamespace = "docker.io"
	// DefaultRegistryHost is the hostname for the default (Docker Hub) registry
	// used for pushing and pulling images. This hostname is hard-coded to handle
	// the conversion from image references without registry name (e.g. "ubuntu",
	// or "ubuntu:latest"), as well as references using the "docker.io" domain
	// name, which is used as canonical reference for images on Docker Hub, but
	// does not match the domain-name of Docker Hub's registry.
	DefaultRegistryHost = "registry-1.docker.io"
	// IndexHostname is the index hostname, used for authentication and image search.
	IndexHostname = "index.docker.io"
	// IndexServer is used for user auth and image search
	IndexServer = "https://" + IndexHostname + "/v1/"
	// IndexName is the name of the index
	IndexName = "docker.io"
)

TODO(thaJeztah) both the "index.docker.io" and "registry-1.docker.io" domains are here for historic reasons and backward-compatibility. These domains are still supported by Docker Hub (and will continue to be supported), but there are new domains already in use, and plans to consolidate all legacy domains to new "canonical" domains. Once those domains are decided on, we should update these consts (but making sure to preserve compatibility with existing installs, clients, and user configuration).

View Source
const AuthClientID = "docker"

AuthClientID is used the ClientID used for the token server

Variables

View Source
var (
	// DefaultV2Registry is the URI of the default (Docker Hub) registry.
	DefaultV2Registry = &url.URL{
		Scheme: "https",
		Host:   DefaultRegistryHost,
	}
)

Functions

func CertsDir

func CertsDir() string

CertsDir is the directory where certificates are stored.

- Linux: "/etc/docker/certs.d/" - Linux (with rootlessKit): $XDG_CONFIG_HOME/docker/certs.d/" or "$HOME/.config/docker/certs.d/" - Windows: "%PROGRAMDATA%/docker/certs.d/"

TODO(thaJeztah): certsDir but stored in our config, and passed when needed. For the CLI, we should also default to same path as rootless.

func ConvertToHostname

func ConvertToHostname(maybeURL string) string

ConvertToHostname normalizes a registry URL which has http|https prepended to just its hostname. It is used to match credentials, which may be either stored as hostname or as hostname including scheme (in legacy configuration files).

func Headers

func Headers(userAgent string, metaHeaders http.Header) []transport.RequestModifier

Headers returns request modifiers with a User-Agent and metaHeaders

func NewStaticCredentialStore

func NewStaticCredentialStore(ac *registry.AuthConfig) auth.CredentialStore

NewStaticCredentialStore returns a credential store which always returns the same credential values.

func PingV2Registry

func PingV2Registry(endpoint *url.URL, authTransport http.RoundTripper) (challenge.Manager, error)

PingV2Registry attempts to ping a v2 registry and on success return a challenge manager for the supported authentication types. If a response is received but cannot be interpreted, a PingResponseError will be returned.

func ValidateIndexName

func ValidateIndexName(val string) (string, error)

ValidateIndexName validates an index name. It is used by the daemon to validate the daemon configuration.

func ValidateMirror

func ValidateMirror(mirrorURL string) (string, error)

ValidateMirror validates and normalizes an HTTP(S) registry mirror. It returns an error if the given mirrorURL is invalid, or the normalized format for the URL otherwise.

It is used by the daemon to validate the daemon configuration.

Types

type APIEndpoint

type APIEndpoint struct {
	Mirror    bool
	URL       *url.URL
	TLSConfig *tls.Config
}

APIEndpoint represents a remote API endpoint

type PingResponseError

type PingResponseError struct {
	Err error
}

PingResponseError is used when the response from a ping was received but invalid.

func (PingResponseError) Error

func (err PingResponseError) Error() string

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is a registry service. It tracks configuration data such as a list of mirrors.

func NewService

func NewService(options ServiceOptions) (*Service, error)

NewService returns a new instance of Service ready to be installed into an engine.

func (*Service) Auth

func (s *Service) Auth(ctx context.Context, authConfig *registry.AuthConfig, userAgent string) (token string, _ error)

Auth contacts the public registry with the provided credentials, and returns OK if authentication was successful. It can be used to verify the validity of a client's credentials.

func (*Service) IsInsecureRegistry

func (s *Service) IsInsecureRegistry(host string) bool

IsInsecureRegistry returns true if the registry at given host is configured as insecure registry.

func (*Service) LookupPullEndpoints

func (s *Service) LookupPullEndpoints(hostname string) ([]APIEndpoint, error)

LookupPullEndpoints creates a list of v2 endpoints to try to pull from, in order of preference. It gives preference to mirrors over the actual registry, and HTTPS over plain HTTP.

func (*Service) LookupPushEndpoints

func (s *Service) LookupPushEndpoints(hostname string) ([]APIEndpoint, error)

LookupPushEndpoints creates a list of v2 endpoints to try to push to, in order of preference. It gives preference to HTTPS over plain HTTP. Mirrors are not included.

func (*Service) ReplaceConfig

func (s *Service) ReplaceConfig(options ServiceOptions) (commit func(), _ error)

ReplaceConfig prepares a transaction which will atomically replace the registry service's configuration when the returned commit function is called.

func (*Service) ResolveAuthConfig

func (s *Service) ResolveAuthConfig(authConfigs map[string]registry.AuthConfig, ref reference.Named) registry.AuthConfig

ResolveAuthConfig looks up authentication for the given reference from the given authConfigs.

IMPORTANT: This function is for internal use and should not be used by external projects.

func (*Service) Search

func (s *Service) Search(ctx context.Context, searchFilters filters.Args, term string, limit int, authConfig *registry.AuthConfig, headers map[string][]string) ([]registry.SearchResult, error)

Search queries the public registry for repositories matching the specified search term and filters.

func (*Service) ServiceConfig

func (s *Service) ServiceConfig() *registry.ServiceConfig

ServiceConfig returns a copy of the public registry service's configuration.

type ServiceOptions

type ServiceOptions struct {
	Mirrors            []string `json:"registry-mirrors,omitempty"`
	InsecureRegistries []string `json:"insecure-registries,omitempty"`
}

ServiceOptions holds command line options.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL