2017-10-04 208 views
0

我下面就搬運工推了「錯誤解析HTTP 405 ...... POST不允許」

https://docs.docker.com/get-started/part2/#conclusion-of-part-two

Docker教程當我跑的docker push的命令,我得到這個錯誤

[[email protected] firstDocker]# docker push leeyuiwah/get-started:part2 
The push refers to a repository [registry.access.redhat.com/leeyuiwah/get-started] 
7a8cded9ffac: Preparing 
77a209967ebf: Preparing 
00d1486114fa: Preparing 
24b02a08f57d: Preparing 
aed9311ebf15: Preparing 
17f9d9d4ce37: Waiting 
18f9b4e2e1bc: Waiting 
error parsing HTTP 405 response body: invalid character '<' looking 
for beginning of value: "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 
Final//EN\">\n<title>405 Method Not Allowed</title>\n 
<h1>Method Not Allowed</h1>\n<p> 
The method POST is not allowed for the requested URL.</p>\n" 

我在互聯網上搜索。已經有在這個論壇上同樣的錯誤 的報道很多,但沒有答案:

https://forums.docker.com/t/docker-push-command-is-throwing-error-405-method-not-allowed/28384/4

我在防火牆後面,但是當我docker run hello-world, 從網上拉圖像,這個命令測試 跑沒有問題。

我使用的版本稍低於教程 的建議。不知道這是否是原因。

[[email protected] firstDocker]# docker --version 
Docker version 1.12.6, build 3a094bd/1.12.6 
+0

從@Ahmed_Rahat,誰沒有足夠的代表發表評論:我在RedHat上,並遵循你所概述的。我得到了和你一樣的結果,但這是否允許你稍後從dockerhub中提取圖像?我做了同樣的工作,推送工作正常,但當我搜索它或當我嘗試碼頭拉時,圖像不在碼頭集線器上。 – FrankerZ

回答

0

檢查您的主機名(特別是如果你是一個RedHat系統上運行)

(CF this bug report with Redhat

我意識到,不給的參數標籤和推命令,我實際上使用不同的註冊表(registry.access.redhat.com而不是hub.docker.com)。

[[email protected] firstDocker]# docker push leeyuiwah/get-started:part2 
The push refers to a repository 
[registry.access.redhat.com/leeyuiwah/get-started] 
Error: Status 404 trying to push repository leeyuiwah/get-started: 
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n 
<title>404 Not Found</title>\n<h1>Not Found</h1>\n 
<p>The requested URL was not found on the server.</p> 
<p>If you entered the URL manually please check your spelling and try again.</p> 
\n" 

所以,現在我明確地設置註冊表,但後來我得到Index response didn't contain any endpoints

[[email protected] firstDocker]# docker-latest tag friendlyhello hub.docker.com/leeyuiwah/get-started:part2 
[[email protected] firstDocker]# docker-latest push hub.docker.com/leeyuiwah/get-started:part2 
The push refers to a repository [hub.docker.com/leeyuiwah/get-started] 
3088bc0df692: Preparing 
fa9c71108753: Preparing 
4cc654f2b860: Preparing 
24b02a08f57d: Preparing 
aed9311ebf15: Preparing 
17f9d9d4ce37: Waiting 
18f9b4e2e1bc: Waiting 
Index response didn't contain any endpoints 

版本

我也切換到使用最新的碼頭工人,以確保公正問題 是不是由於版本。

[[email protected] firstDocker]# docker-latest --version 
Docker version 1.13.1, build 6774275/1.13.1 

虛假響應docker login

我還注意到的一件事是login命令一直給 我僞造了Login Succeeded響應。這可能是一個因素嗎?

[[email protected] firstDocker]# docker-latest login hub.docker.com 
Username (leeyuiwah): bogus (I don't think this is a valid account) 
Password:     (just type in some junk) 
Login Succeeded 

測試與本地自託管註冊表

(C.F. Docker Doc: Run a local registry

我能得到推動與當地自託管登記工作。不過我 是使用僞造的登錄

安裝本地自託管註冊表

[[email protected] firstDocker]# docker run -d -p 5000:5000 --restart=always --name registry registry:2 
Unable to find image 'registry:2' locally 
Trying to pull repository registry.access.redhat.com/registry ... 
Trying to pull repository docker.io/library/registry ... 
2: Pulling from docker.io/library/registry 
90f4dba627d6: Pull complete 
b3e11d7b4f5e: Pull complete 
1f032f3c8932: Pull complete 
425585e7aedb: Pull complete 
f45f535a83d2: Pull complete 
Digest: sha256:0f8fe61fa337b8ef02217702ba979b47a7d68717d4628f31592ebff85915f3ba 
37f70dbd0e4f96707d07579c8ab8577032cefa9142af0c13c2dace23adda213a 

做一個假的登錄

[[email protected] firstDocker]# docker-latest login localhost:5000 
Username: dkfjld  (bogus account name) 
Password:    (bogus password) 
Login Succeeded   (this still bugs me!) 

標籤,然後按==>這一次,它的工作原理!

[[email protected] firstDocker]# docker-latest tag friendlyhello localhost:5000/leeyuiwah/get-started:part2 
[[email protected] firstDocker]# docker-latest push localhost:5000/leeyuiwah/get-started:part2 
The push refers to a repository [localhost:5000/leeyuiwah/get-started] 
3088bc0df692: Pushed 
fa9c71108753: Pushed 
4cc654f2b860: Pushed 
24b02a08f57d: Pushed 
aed9311ebf15: Pushed 
17f9d9d4ce37: Pushed 
18f9b4e2e1bc: Pushed 
part2: digest: sha256:23c9720ee308ab6fa6ec8b0c23c40fadc7562fe34352d64b2322f43a90dfec0b size: 1787