leeyuiwah
leeyuiwah

Reputation: 7152

docker push got "error parsing HTTP 405 ... POST not allowed"

I am following the Docker tutorial on

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

When I ran the command of docker push, I got this error

[root@pecan-9 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"

I googled on the Internet. There have been many reports of the same error on this forum, but no answer:

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

I am behind a firewall, but when I tested with docker run hello-world, pulling image from the Internet, this command ran without problem.

I am using a version that is slight lower than what the tutorial suggests. Not sure if this would be the cause.

[root@pecan-9 firstDocker]# docker --version
Docker version 1.12.6, build 3a094bd/1.12.6

Upvotes: 4

Views: 9473

Answers (2)

Ali Mahdavi
Ali Mahdavi

Reputation: 1

please change leeyuiwah/get-started:part2 to registry.access.redhat.com:http or https port:part2

Upvotes: 0

leeyuiwah
leeyuiwah

Reputation: 7152

Check your hostname (especially if you are running on a RedHat system)

(c.f. this bug report with Redhat)

I realized that by not giving an argument to the tag and push command, I am actually using a different registry (registry.access.redhat.com instead of hub.docker.com).

[root@pecan-9A 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"

So now I explicitly set the registry, but then I got Index response didn't contain any endpoints

[root@pecan-9A firstDocker]# docker-latest tag friendlyhello hub.docker.com/leeyuiwah/get-started:part2
[root@pecan-9A 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

Version

I also switched to use the latest docker just to make sure the problem was not due to version.

[root@pecan-9A firstDocker]# docker-latest --version
Docker version 1.13.1, build 6774275/1.13.1

Bogus response for docker login?

One more thing that I notice is the login command has been giving me bogus response of Login Succeeded. Could this be a factor?

[root@pecan-9A 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

Test with a local self-hosted registry

(c.f. Docker Doc: Run a local registry)

I could get the push working with a local self-hosted registry. Still I was using a bogus login

Install a local self-hosted registry

[root@pecan-9A 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

Make a bogus login

[root@pecan-9A firstDocker]# docker-latest login localhost:5000
Username: dkfjld        (bogus account name)
Password:               (bogus password)
Login Succeeded         (this still bugs me!)

Tag and then push ==> This time it works!

[root@pecan-9A firstDocker]# docker-latest  tag friendlyhello localhost:5000/leeyuiwah/get-started:part2
[root@pecan-9A 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

Upvotes: 1

Related Questions