简体   繁体   English

Windows上的Docker私有注册表:服务不可用

[英]Docker Private Registry on Windows: Service Unavailable

I want to run a private Docker registry on Windows. 我想在Windows上运行私有Docker注册表。 Since Docker only includes a Linux registry image, I need to create one. 由于Docker仅包含Linux注册表映像,因此我需要创建一个。 However, I'm encountering a very vague error. 但是,我遇到一个非常模糊的错误。

I get the following error when attempting to run a new private docker registry on Windows: 尝试在Windows上运行新的私有Docker注册表时出现以下错误:

When visiting the registry service url http://docker_registry:5000/ , it throws this error: 当访问注册表服务URL http:// docker_registry:5000 /时 ,它将引发以下错误:

{"errors":[{"code":"UNAVAILABLE","message":"service unavailable","detail":"health check failed: please see /debug/health"}]}

Run Command: 运行命令:

docker run -d -p 5000:5000 -h docker_registry --restart=always --name registry -v C:\registry:C:\data win-registry

WinRegistry.Dockerfile.build WinRegistry.Dockerfile.build

FROM golang:1.8-windowsservercore AS builder
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ARG REGISTRY_VERSION=v2.6.1

WORKDIR C:\\gopath\\src\\github.com\\docker

RUN git clone https://github.com/docker/distribution.git --branch release/2.6; cd distribution; git checkout $env:REGISTRY_VERSION; go build -o C:\out\registry.exe .\cmd\registry

# registry image
FROM microsoft/nanoserver:10.0.14393.1358
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV DATA_PATH="C:\data"
ENV REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY="G:\\"
RUN Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices' -Name 'G:' -Value "\??\$($env:DATA_PATH)" -Type String
VOLUME ${DATA_PATH}

EXPOSE 5000

COPY --from=builder C:\\out\\registry.exe /registry/registry.exe

COPY ./config.yml /registry/config.yml
#COPY --from=builder C:\\gopath\\src\\github.com\\docker\\distribution\\cmd\\registry\\config-example.yml /registry/config.yml

WORKDIR /registry
ENTRYPOINT ["registry", "serve", "config.yml"]

config.yml 配置文件

version: 0.1
log:
  level: debug
  fields:
    service: registry
    environment: development
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /data
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3

Container Logs: 容器日志:

time="2017-08-22T18:26:44.5897177-07:00" level=warning msg="No HTTP secret provided - generated random secret. This may cause problems with uploads if multiple registries are behind a load-balancer. To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment
variable." environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry version="v2.6.0+unknown"
time="2017-08-22T18:26:44.5897177-07:00" level=info msg="redis not configured" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry version="v2.6.0+unknown"
time="2017-08-22T18:26:44.5897177-07:00" level=info msg="Starting upload purge in 52m0s" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry version="v2.6.0+unknown"
time="2017-08-22T18:26:44.6155976-07:00" level=info msg="using inmemory blob descriptor cache" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry version="v2.6.0+unknown"
time="2017-08-22T18:26:44.6155976-07:00" level=info msg="listening on [::]:5000" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry version="v2.6.0+unknown"
time="2017-08-22T18:26:54.6155393-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=080c8f5d-f387-4f19-b7cc-96d58664cff3 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:27:04.6162491-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=42f20013-6b73-49df-bf3d-892faa6fe7cb trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:27:14.6152129-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=41047fed-0ec8-4f27-8c7f-586546010ee3 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:27:24.6156255-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=1a95464a-562f-45a6-9bbf-33e32065420e trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:27:34.6137309-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=786cde57-94d1-4271-907d-15966bc99de1 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:27:44.6137547-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=db13c00e-fed3-4318-a0ab-f5be643d8ef2 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:27:54.6137251-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=4e9e562e-c5e6-4867-ad95-8c85daa1c0bf trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:28:04.6134341-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=049af9b3-991d-407d-8ef7-c37a395939e3 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:28:14.612824-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="gi
thub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=07a04b70-2b52-4078-b951-f905b1692592 trace.line=137 version="v2.6.0+unknown"
172.31.176.1 - - [22/Aug/2017:18:28:17 -0700] "GET / HTTP/1.1" 503 125 "" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36"
172.31.176.1 - - [22/Aug/2017:18:28:17 -0700] "GET /favicon.ico HTTP/1.1" 503 125 "http://docker_registry:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36"
time="2017-08-22T18:28:24.6135145-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=fe541b27-19c7-4f2a-8d2b-666c54edae73 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:28:34.6122542-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=3cab06a5-d292-423a-bc33-d235955c115f trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:28:44.6129509-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=71092e44-af4d-455c-9974-7e69fadf8ed8 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:28:54.6116187-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=539f6fda-0f6c-46d4-9065-fe797b37e24e trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:29:04.6113486-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=0116bf34-f388-4806-b58d-8b9305a34ea2 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:29:14.6100291-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=cf0caa16-e1c5-4300-8767-34413eca5684 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:29:24.6107459-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=eeb5a4db-8e32-40dc-a3f0-9dee68b0f4fb trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:29:34.6094988-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=faff0c19-159c-4a6e-a524-1ab993279877 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:29:44.6092487-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=e4b7b03f-9c89-41be-b587-a617a8857f79 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:29:54.6094671-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=ae453856-2dfe-4508-badd-f52abaa9868d trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:30:04.6087548-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=006e797c-8ce0-4f4b-ba30-4952158e14f7 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:30:14.6094661-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=e1fa00b6-ec08-4a45-b9e0-cb0df98efbbe trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:30:24.6081668-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=5d8c9275-5add-453f-84b3-581d7b5cef5c trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:30:34.6078667-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=b051cd70-1581-4464-912b-41e554db0667 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:30:44.6085794-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=3588b076-28be-4d25-a1ac-281760ebb98a trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:30:54.6082941-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=c790cb8b-b701-4883-ac75-d3b32c11e38c trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:31:04.6059659-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=dfdba655-a2ef-471a-9503-36df1e6e9747 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:31:14.6055735-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=ef037d2f-c371-462d-b9fa-bbf680270e49 trace.line=137 version="v2.6.0+unknown"
time="2017-08-22T18:31:24.6057266-07:00" level=debug msg="filesystem.Stat(\"/\")" environment=development go.version=go1.8.3 instance.id=1c46e684-314b-4ac4-9699-f324a449caae service=registry trace.duration=0s trace.file="C:/gopath/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="g
ithub.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=58ca4ce7-9042-46bc-a0e4-3f118fbcec02 trace.line=137 version="v2.6.0+unknown"

Docker images are now multi platform: https://blog.docker.com/2017/09/docker-official-images-now-multi-platform/ Docker映像现在是多平台的: https : //blog.docker.com/2017/09/docker-official-images-now-multi-platform/

There is a Dockerfile for running the registry on Windows. 有一个用于在Windows上运行注册表的Dockerfile。 I would recommend avoiding using third party images though. 我建议您避免使用第三方图片。 https://hub.docker.com/r/stefanscherer/registry-windows/ https://hub.docker.com/r/stefanscherer/registry-windows/

FROM golang:1-windowsservercore as gobuild

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV DOCKER_BUILDTAGS include_oss include_gcs
ENV DISTRIBUTION_VERSION v2.6.2

# ENV GIT_VERSION 2.11.0
# ENV GIT_DOWNLOAD_URL https://github.com/git-for-windows/git/releases/download/v${GIT_VERSION}.windows.1/MinGit-${GIT_VERSION}-64-bit.zip
#
# RUN Invoke-WebRequest -UseBasicParsing $env:GIT_DOWNLOAD_URL -OutFile git.zip; \
#     Expand-Archive git.zip -DestinationPath C:\git; \
#     Remove-Item git.zip; \
#     Write-Host 'Updating PATH ...'; \
#     $env:PATH = 'C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin;' + $env:PATH; \
#     Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH

RUN mkdir src\github.com\docker ; \
    cd src\github.com\docker ; \
    git clone -q https://github.com/docker/distribution ; \
    cd distribution ; \
    git checkout -q $env:DISTRIBUTION_VERSION ; \
    try { go get github.com/tools/godep 2>&1 } catch { } ; \
    try { go get github.com/tools/godep } catch { } ; \
    Start-Process -FilePath godep.exe -ArgumentList go, build, ./cmd/registry -Wait

FROM microsoft/nanoserver

COPY --from=gobuild /gopath/src/github.com/docker/distribution/registry.exe /registry.exe
COPY config.yml /config/config.yml

VOLUME C:\\registry
EXPOSE 5000

ENTRYPOINT ["\\registry.exe"]
CMD ["serve", "/config/config.yml"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM