问题描述:
使用 HTTP 模式安装好了 VMware Harbor,但是, 使用的时候发现:
使用docker push 命令推镜像的时候, 失败了,
自然, web界面上也看不到镜像。
解决办法要点:
1. 确认配置正确,
可以 独立 run 一个registry的容器,实验一下配置是否正确
2. 使用docker login 命令先登录
docker login -u admin -p Harbor12345 -e sample_admin@mydomain.com 172.30.0.20:5000
3. 给镜像打标签的时候, 要多一层 library, 这个是缺省的, 否则要建立好了project,才能推镜像
docker tag busybox 172.30.0.20:5000/library/my
详细过程
1. 不正确的操作示例
客户端:[root@ip-172-30-0-20 ~]# docker push 172.30.0.20:5000/busybox:cloud
The push refers to a repository [172.30.0.20:5000/busybox]
5f70bf18a086: Image push failed
1834950e52ce: Image push failed
unauthorized: authentication required
[root@ip-172-30-0-20 ~]#
服务器端:
registry_1 | time="2016-06-08T11:02:29.929222341Z" level=debug msg="authorizing request" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=300a9dbe-6027-41bb-a9a3-64e7eaf68f76 http.request.method=GET http.request.remoteaddr="172.30.0.20:41271" http.request.uri="/v2/" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry version=v2.4.0
registry_1 | time="2016-06-08T11:02:29.929388489Z" level=warning msg="error authorizing context: authorization token required" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=300a9dbe-6027-41bb-a9a3-64e7eaf68f76 http.request.method=GET http.request.remoteaddr="172.30.0.20:41271" http.request.uri="/v2/" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry version=v2.4.0
registry_1 | 172.30.0.20 - - [08/Jun/2016:11:02:29 +0000] "GET /v2/ HTTP/1.1" 401 87 "" "docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64"
ui_1 | 2016-06-08T11:02:29Z [INFO] request url: /service/token?scope=repository%3Abusybox%3Apush%2Cpull&service=token-service
ui_1 | 2016-06-08T11:02:29Z [DEBUG] [authenticator.go:52]: Current AUTH_MODE is db_auth
ui_1 | 2016-06-08T11:02:29Z [DEBUG] [authutils.go:42]: scopes: [repository:busybox:push,pull]
ui_1 | 2016-06-08T11:02:29Z [INFO] current access, type: repository, name:busybox, actions:[]
ui_1 | 2016/06/08 11:02:29 [router.go:828][D] | GET | /service/token | 36.754061ms | match | /service/token |
registry_1 | time="2016-06-08T11:02:29.973905388Z" level=debug msg="authorizing request" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=f7031b1d-2055-43db-8bcc-a587d95dc1bf http.request.method=HEAD http.request.remoteaddr="172.30.0.20:41275" http.request.uri="/v2/busybox/blobs/sha256:385e281300cc6d88bdd155e0931fbdfbb1801c2b0265340a40481ee2b733ae66" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry vars.digest="sha256:385e281300cc6d88bdd155e0931fbdfbb1801c2b0265340a40481ee2b733ae66" vars.name=busybox version=v2.4.0
registry_1 | time="2016-06-08T11:02:29.974703102Z" level=warning msg="error authorizing context: insufficient scope" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=f7031b1d-2055-43db-8bcc-a587d95dc1bf http.request.method=HEAD http.request.remoteaddr="172.30.0.20:41275" http.request.uri="/v2/busybox/blobs/sha256:385e281300cc6d88bdd155e0931fbdfbb1801c2b0265340a40481ee2b733ae66" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry vars.digest="sha256:385e281300cc6d88bdd155e0931fbdfbb1801c2b0265340a40481ee2b733ae66" vars.name=busybox version=v2.4.0
registry_1 | 172.30.0.20 - - [08/Jun/2016:11:02:29 +0000] "HEAD /v2/busybox/blobs/sha256:385e281300cc6d88bdd155e0931fbdfbb1801c2b0265340a40481ee2b733ae66 HTTP/1.1" 401 139 "" "docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64"
registry_1 | time="2016-06-08T11:02:29.975992181Z" level=debug msg="authorizing request" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=2aed3a1d-8bd2-4b4a-9507-9aa01f76d009 http.request.method=HEAD http.request.remoteaddr="172.30.0.20:41274" http.request.uri="/v2/busybox/blobs/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry vars.digest="sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" vars.name=busybox version=v2.4.0
registry_1 | time="2016-06-08T11:02:29.976514194Z" level=warning msg="error authorizing context: insufficient scope" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=2aed3a1d-8bd2-4b4a-9507-9aa01f76d009 http.request.method=HEAD http.request.remoteaddr="172.30.0.20:41274" http.request.uri="/v2/busybox/blobs/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry vars.digest="sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" vars.name=busybox version=v2.4.0
registry_1 | 172.30.0.20 - - [08/Jun/2016:11:02:29 +0000] "HEAD /v2/busybox/blobs/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4 HTTP/1.1" 401 139 "" "docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64"
proxy_1 | 54.172.254.196 - - [08/Jun/2016:11:02:29 +0000] "GET /service/token?scope=repository%3Abusybox%3Apush%2Cpull&service=token-service HTTP/1.1" 200 1157 "-" "docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64"
解决:
a。登录
[root@ip-172-30-0-20 ~]# docker login -u admin -p Harbor12345 -e sample_admin@mydomain.com 172.30.0.20:5000
WARNING: login credentials saved in /root/.docker/config.json
Login Succeeded
[root@ip-172-30-0-20 ~]#
b。文件内容
"auths": {
"172.30.0.20:5000": {
"auth": "YWRtaW46SGFyYm9yMTIzNDU=",
"email": "sample_admin@mydomain.com"
}
}
}
c。服务器端输出
registry_1 | time="2016-06-08T11:08:27.101055472Z" level=debug msg="authorizing request" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=4fb2a7ec-9446-4e09-8c13-5fb71f091261 http.request.method=GET http.request.remoteaddr="172.30.0.20:41278" http.request.uri="/v2/" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry version=v2.4.0
registry_1 | time="2016-06-08T11:08:27.101137779Z" level=warning msg="error authorizing context: authorization token required" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=4fb2a7ec-9446-4e09-8c13-5fb71f091261 http.request.method=GET http.request.remoteaddr="172.30.0.20:41278" http.request.uri="/v2/" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry version=v2.4.0
registry_1 | 172.30.0.20 - - [08/Jun/2016:11:08:27 +0000] "GET /v2/ HTTP/1.1" 401 87 "" "docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64"
ui_1 | 2016-06-08T11:08:27Z [INFO] request url: /service/token?account=admin&service=token-service
ui_1 | 2016-06-08T11:08:27Z [DEBUG] [authenticator.go:52]: Current AUTH_MODE is db_auth
ui_1 | 2016-06-08T11:08:27Z [DEBUG] [authutils.go:42]: scopes: []
ui_1 | 2016/06/08 11:08:27 [router.go:828][D] | GET | /service/token | 29.821542ms | match | /service/token |
registry_1 | time="2016-06-08T11:08:27.137128678Z" level=debug msg="authorizing request" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=6a912eb4-3932-43fe-bdff-6e84c45d70a4 http.request.method=GET http.request.remoteaddr="172.30.0.20:41281" http.request.uri="/v2/" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry version=v2.4.0
registry_1 | time="2016-06-08T11:08:27.13791445Z" level=info msg="response completed" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=6a912eb4-3932-43fe-bdff-6e84c45d70a4 http.request.method=GET http.request.remoteaddr="172.30.0.20:41281" http.request.uri="/v2/" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" http.response.contenttype="application/json; charset=utf-8" http.response.duration=1.934938ms http.response.status=200 http.response.written=2 instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry version=v2.4.0
registry_1 | 172.30.0.20 - - [08/Jun/2016:11:08:27 +0000] "GET /v2/ HTTP/1.1" 200 2 "" "docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64"
proxy_1 | 54.172.254.196 - admin [08/Jun/2016:11:08:27 +0000] "GET /service/token?account=admin&service=token-service HTTP/1.1" 200 1099 "-" "docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64"
d。 上传 image客户端
[root@ip-172-30-0-20 ~]# docker tag busybox 172.30.0.20:5000/library/my
[root@ip-172-30-0-20 ~]# docker push 172.30.0.20:5000/library/my
The push refers to a repository [172.30.0.20:5000/library/my]
5f70bf18a086: Pushed
1834950e52ce: Pushed
latest: digest: sha256:6757d4b17cd75742fc3b1fc1a8d02b45b637f2ac913ee9669f5c2aed0c9b26ba size: 711
[root@ip-172-30-0-20 ~]#
e。服务器端输出
。。。。。。。。
ui_1 | 2016/06/08 11:30:57 [router.go:828][D] | POST | /service/notifications | 190.034µs | match | /service/notifications |
ui_1 | 2016/06/08 11:30:57 [router.go:828][D] | POST | /service/notifications | 129.273µs | match | /service/notifications |
registry_1 | time="2016-06-08T11:30:57.467393644Z" level=debug msg="filesystem.PutContent(\"/docker/registry/v2/repositories/library/my/_uploads/fc09f50f-40c6-4d23-9de2-3da6809135dc/hashstates/sha256/32\")" auth.user.name=admin go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=c542aa68-6394-4e88-b199-ac33cea3ba5c http.request.method=PUT http.request.remoteaddr="172.30.0.20:41387" http.request.uri="/v2/library/my/blobs/uploads/fc09f50f-40c6-4d23-9de2-3da6809135dc?_state=1Ocz-7gnHsotN8b7_xWRhdGa68KO66pPPYB7MNJS0B57Ik5hbWUiOiJsaWJyYXJ5L215IiwiVVVJRCI6ImZjMDlmNTBmLTQwYzYtNGQyMy05ZGUyLTNkYTY4MDkxMzVkYyIsIk9mZnNldCI6MzIsIlN0YXJ0ZWRBdCI6IjIwMTYtMDYtMDhUMTE6MzA6NTZaIn0%3D&digest=sha256%3Aa3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry trace.duration=4.430229ms trace.file="/go/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="github.com/docker/distribution/registry/storage/driver/base.(*Base).PutContent" trace.id=fb876aa5-13fb-4ac9-bcb6-5a6a49824360 trace.line=95 vars.name="library/my" vars.uuid=fc09f50f-40c6-4d23-9de2-3da6809135dc version=v2.4.0
registry_1 | time="2016-06-08T11:30:57.4674827Z" level=info msg="response completed" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=c542aa68-6394-4e88-b199-ac33cea3ba5c http.request.method=PUT http.request.remoteaddr="172.30.0.20:41387" http.request.uri="/v2/library/my/blobs/uploads/fc09f50f-40c6-4d23-9de2-3da6809135dc?_state=1Ocz-7gnHsotN8b7_xWRhdGa68KO66pPPYB7MNJS0B57Ik5hbWUiOiJsaWJyYXJ5L215IiwiVVVJRCI6ImZjMDlmNTBmLTQwYzYtNGQyMy05ZGUyLTNkYTY4MDkxMzVkYyIsIk9mZnNldCI6MzIsIlN0YXJ0ZWRBdCI6IjIwMTYtMDYtMDhUMTE6MzA6NTZaIn0%3D&digest=sha256%3Aa3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" http.response.duration=17.344638ms http.response.status=201 http.response.written=0 instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry version=v2.4.0
registry_1 | 172.30.0.20 - - [08/Jun/2016:11:30:57 +0000] "PUT /v2/library/my/blobs/uploads/fc09f50f-40c6-4d23-9de2-3da6809135dc?_state=1Ocz-7gnHsotN8b7_xWRhdGa68KO66pPPYB7MNJS0B57Ik5hbWUiOiJsaWJyYXJ5L215IiwiVVVJRCI6ImZjMDlmNTBmLTQwYzYtNGQyMy05ZGUyLTNkYTY4MDkxMzVkYyIsIk9mZnNldCI6MzIsIlN0YXJ0ZWRBdCI6IjIwMTYtMDYtMDhUMTE6MzA6NTZaIn0%3D&digest=sha256%3Aa3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4 HTTP/1.1" 201 0 "" "docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64"
registry_1 | time="2016-06-08T11:30:57.469954822Z" level=debug msg="authorizing request" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=53d3f1bc-f7aa-46b7-9805-3f15223668d2 http.request.method=HEAD http.request.remoteaddr="172.30.0.20:41391" http.request.uri="/v2/library/my/blobs/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry vars.digest="sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" vars.name="library/my" version=v2.4.0
registry_1 | time="2016-06-08T11:30:57.470411841Z" level=debug msg=GetBlob auth.user.name=admin go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=53d3f1bc-f7aa-46b7-9805-3f15223668d2 http.request.method=HEAD http.request.remoteaddr="172.30.0.20:41391" http.request.uri="/v2/library/my/blobs/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry vars.digest="sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" vars.name="library/my" version=v2.4.0
registry_1 | time="2016-06-08T11:30:57.470494155Z" level=debug msg="filesystem.URLFor(\"/docker/registry/v2/blobs/sha256/a3/a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4/data\")" auth.user.name=admin go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=53d3f1bc-f7aa-46b7-9805-3f15223668d2 http.request.method=HEAD http.request.remoteaddr="172.30.0.20:41391" http.request.uri="/v2/library/my/blobs/sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" http.request.useragent="docker/1.10.3-cs3 go/go1.5.4 git-commit/6df5588 kernel/3.10.0-327.el7.x86_64 os/linux arch/amd64" instance.id=71df9a7e-0ec8-4522-8978-bbd01813541f service=registry trace.duration=11.125µs trace.file="/go/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="github.com/docker/distribution/registry/storage/driver/base.(*Base).URLFor" trace.id=f148fdfd-97ed-4aa9-9cac-f7179e81cb09 trace.line=189 vars.digest="sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4" vars.name="library/my" version=v2.4.0
registry_1 | time="2016-06-08T11:30:57.47060991Z" level=info msg="response completed" go.version=go1.6.1 http.request.host="172.30.0.20:5000" http.request.id=53d3f1bc-f7aa-46b7-9805-3f