Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions images/dockerregistry/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN INSTALL_PKGS="origin-dockerregistry" && \
COPY config.yml ${REGISTRY_CONFIGURATION_PATH}

LABEL io.k8s.display-name="OpenShift Container Platform Image Registry" \
io.k8s.description="This is a component ofOpenShift Container Platform and exposes a Docker registry that is integrated with the cluster for authentication and management." \
io.k8s.description="This is a component of OpenShift Container Platform and exposes a Docker registry that is integrated with the cluster for authentication and management." \
io.openshift.tags="openshift,docker,registry"

# The registry doesn't require a root user.
Expand All @@ -23,4 +23,4 @@ EXPOSE 5000
VOLUME /registry
ENV REGISTRY_CONFIGURATION_PATH=/config.yml

CMD DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_SERVICE_HOST}:${DOCKER_REGISTRY_SERVICE_PORT} /usr/bin/dockerregistry ${REGISTRY_CONFIGURATION_PATH}
CMD /usr/bin/dockerregistry ${REGISTRY_CONFIGURATION_PATH}
5 changes: 2 additions & 3 deletions images/dockerregistry/Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ RUN INSTALL_PKGS="origin-dockerregistry" && \
COPY config.yml ${REGISTRY_CONFIGURATION_PATH}

LABEL io.k8s.display-name="OpenShift Container Platform Image Registry" \
io.k8s.description="This is a component ofOpenShift Container Platform and exposes a Docker registry that is integrated with the cluster for authentication and management." \
io.k8s.description="This is a component of OpenShift Container Platform and exposes a Docker registry that is integrated with the cluster for authentication and management." \
io.openshift.tags="openshift,docker,registry"

# The registry doesn't require a root user.
USER 1001
EXPOSE 5000
VOLUME /registry
ENV REGISTRY_CONFIGURATION_PATH=/config.yml \
DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_SERVICE_HOST}:${DOCKER_REGISTRY_SERVICE_PORT}
ENV REGISTRY_CONFIGURATION_PATH=/config.yml

CMD /usr/bin/dockerregistry ${REGISTRY_CONFIGURATION_PATH}
2 changes: 1 addition & 1 deletion pkg/dockerregistry/server/blobdescriptorservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestBlobDescriptorServiceIsApplied(t *testing.T) {
if err != nil {
t.Fatalf("error parsing server url: %v", err)
}
os.Setenv("DOCKER_REGISTRY_URL", serverURL.Host)
os.Setenv("OPENSHIFT_DEFAULT_REGISTRY", serverURL.Host)

desc, _, err := registrytest.UploadRandomTestBlob(serverURL, nil, "user/app")
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/dockerregistry/server/pullthroughblobstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestPullthroughServeBlob(t *testing.T) {
if err != nil {
t.Fatalf("error parsing server url: %v", err)
}
os.Setenv("DOCKER_REGISTRY_URL", serverURL.Host)
os.Setenv("OPENSHIFT_DEFAULT_REGISTRY", serverURL.Host)
testImage.DockerImageReference = fmt.Sprintf("%s/%s@%s", serverURL.Host, repoName, testImage.Name)

fos, client := registrytest.NewFakeOpenShiftWithClient()
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestPullthroughServeNotSeekableBlob(t *testing.T) {
if err != nil {
t.Fatalf("error parsing server url: %v", err)
}
os.Setenv("DOCKER_REGISTRY_URL", serverURL.Host)
os.Setenv("OPENSHIFT_DEFAULT_REGISTRY", serverURL.Host)

testImage, err := registrytest.NewImageForManifest(repoName, registrytest.SampleImageManifestSchema1, "", false)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func createTestRegistryServer(t *testing.T, ctx context.Context) *httptest.Serve
if err != nil {
t.Fatalf("error parsing server url: %v", err)
}
os.Setenv("DOCKER_REGISTRY_URL", serverURL.Host)
os.Setenv("OPENSHIFT_DEFAULT_REGISTRY", serverURL.Host)

return remoteRegistryServer
}
Expand Down
20 changes: 19 additions & 1 deletion pkg/dockerregistry/server/repositorymiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ const (

// DockerRegistryURLEnvVar is a mandatory environment variable name specifying url of internal docker
// registry. All references to pushed images will be prefixed with its value.
// DEPRECATED: Use the OPENSHIFT_DEFAULT_REGISTRY instead.
DockerRegistryURLEnvVar = "DOCKER_REGISTRY_URL"

// OpenShiftDefaultRegistry overrides the DockerRegistryURLEnvVar as in OpenShift the
// default registry URL is controller by this environment variable.
OpenShiftDefaultRegistry = "OPENSHIFT_DEFAULT_REGISTRY"

// EnforceQuotaEnvVar is a boolean environment variable that allows to turn quota enforcement on or off.
// By default, quota enforcement is off. It overrides openshift middleware configuration option.
// Recognized values are "true" and "false".
Expand Down Expand Up @@ -165,10 +170,23 @@ func newRepositoryWithClient(
repo distribution.Repository,
options map[string]interface{},
) (distribution.Repository, error) {
// TODO: Deprecate this environment variable.
registryAddr := os.Getenv(DockerRegistryURLEnvVar)
if len(registryAddr) == 0 {
return nil, fmt.Errorf("%s is required", DockerRegistryURLEnvVar)
registryAddr = os.Getenv(OpenShiftDefaultRegistry)
} else {
context.GetLogger(ctx).Infof("DEPRECATED: %q is deprecated, use the %q instead", DockerRegistryURLEnvVar, OpenShiftDefaultRegistry)
}
// TODO: This is a fallback to assuming there is a service named 'docker-registry'. This
// might change in the future and we should make this configurable.
if len(registryAddr) == 0 {
if len(os.Getenv("DOCKER_REGISTRY_SERVICE_HOST")) > 0 && len(os.Getenv("DOCKER_REGISTRY_SERVICE_PORT")) > 0 {
registryAddr = os.Getenv("DOCKER_REGISTRY_SERVICE_HOST") + ":" + os.Getenv("DOCKER_REGISTRY_SERVICE_PORT")
} else {
return nil, fmt.Errorf("%s variable must be set when running outside of Kubernetes cluster", DockerRegistryURLEnvVar)
}
}
context.GetLogger(ctx).Infof("Using %q as Docker Registry URL", registryAddr)

acceptschema2, err := getBoolOption(AcceptSchema2EnvVar, "acceptschema2", true, options)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/dockerregistry/server/signaturedispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestSignatureGet(t *testing.T) {
if err != nil {
t.Fatalf("error parsing server url: %v", err)
}
os.Setenv("DOCKER_REGISTRY_URL", serverURL.Host)
os.Setenv("OPENSHIFT_DEFAULT_REGISTRY", serverURL.Host)

url := fmt.Sprintf("http://%s/extensions/v2/user/app/signatures/%s", serverURL.Host, testImage.Name)

Expand Down Expand Up @@ -189,7 +189,7 @@ func TestSignaturePut(t *testing.T) {
if err != nil {
t.Fatalf("error parsing server url: %v", err)
}
os.Setenv("DOCKER_REGISTRY_URL", serverURL.Host)
os.Setenv("OPENSHIFT_DEFAULT_REGISTRY", serverURL.Host)

signData, err := json.Marshal(testSignature)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/dockerregistry_pullthrough_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ middleware:
storage:
- name: openshift
`
os.Setenv("DOCKER_REGISTRY_URL", "127.0.0.1:5000")
os.Setenv("OPENSHIFT_DEFAULT_REGISTRY", "127.0.0.1:5000")

go dockerregistry.Execute(strings.NewReader(config))

Expand Down
2 changes: 1 addition & 1 deletion test/integration/v2_docker_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ middleware:
os.Setenv("OPENSHIFT_CERT_DATA", string(clusterAdminClientConfig.CertData))
os.Setenv("OPENSHIFT_KEY_DATA", string(clusterAdminClientConfig.KeyData))
os.Setenv("OPENSHIFT_MASTER", clusterAdminClientConfig.Host)
os.Setenv("DOCKER_REGISTRY_URL", "127.0.0.1:5000")
os.Setenv("OPENSHIFT_DEFAULT_REGISTRY", "127.0.0.1:5000")

go dockerregistry.Execute(strings.NewReader(config))

Expand Down