Docker Community Forums

Share and learn in the Docker community.

Error uploading image into Docker Registry using API v2


(Parug1987) #1

I am trying to upload Docker image (tarball) into private Docker registry using Registry API v2.

Step 1: Initiate the upload and get Location URL
$ curl -v -X POST http://localhost:5000/v2/hello-world/blobs/uploads/ * About to connect() to localhost port 5000 (#0)

  • Trying ::1…
  • Connected to localhost (::1) port 5000 (#0)

POST /v2/hello-world/blobs/uploads/ HTTP/1.1
User-Agent: curl/7.29.0
Host: localhost:5000
Accept: /

< HTTP/1.1 202 Accepted
< Content-Length: 0
< Docker-Distribution-Api-Version: registry/2.0
< Docker-Upload-Uuid: dd319793-f017-45b3-afe4-c8102363a8df
< Location: http://localhost:5000/v2/hello-world/blobs/uploads/dd319793-f017-45b3-afe4-c8102363a8df?_state=SB2605fFM_7KNkYTHjVrVQVT62dufwXNTw9QzO2_aRR7Ik5hbWUiOiJoZWxsby13b3JsZCIsIlVVSUQiOiJkZDMxOTc5My1mMDE3LTQ1YjMtYWZlNC1jODEwMjM2M2E4ZGYiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMTUtMTAtMjdUMjI6MjU6MjEuMTM0MTI5MDNaIn0%3D
< Range: 0-0
< Date: Tue, 27 Oct 2015 22:25:21 GMT
< Content-Type: text/plain; charset=utf-8
<

  • Connection #0 to host localhost left intact

Step 2: Use location URL to upload the actual Docker image
$ curl -v -H “Content-type: application/octet-stream” -H “Content-Length: 13824” --data-binary @/tmp/hello-world.tar -X PUT -L “http://localhost:5000/v2/hello-world/blobs/uploads/dd319793-f017-45b3-afe4-c8102363a8df?_state=SB2605fFM_7KNkYTHjVrVQVT62dufwXNTw9QzO2_aRR7Ik5hbWUiOiJoZWxsby13b3JsZCIsIlVVSUQiOiJkZDMxOTc5My1mMDE3LTQ1YjMtYWZlNC1jODEwMjM2M2E4ZGYiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMTUtMTAtMjdUMjI6MjU6MjEuMTM0MTI5MDNaIn0%3D&digest=tarsum.v2+sha256:97bbb955c700a6414fd48ae147986e9b42c0508c8a766cea61e7e3badf0f7dde

  • About to connect() to localhost port 5000 (#0)
  • Trying ::1…
  • Connected to localhost (::1) port 5000 (#0)

PUT /v2/hello-world/blobs/uploads/dd319793-f017-45b3-afe4-c8102363a8df?_state=SB2605fFM_7KNkYTHjVrVQVT62dufwXNTw9QzO2_aRR7Ik5hbWUiOiJoZWxsby13b3JsZCIsIlVVSUQiOiJkZDMxOTc5My1mMDE3LTQ1YjMtYWZlNC1jODEwMjM2M2E4ZGYiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMTUtMTAtMjdUMjI6MjU6MjEuMTM0MTI5MDNaIn0%3D&digest=tarsum.v2+sha256:97bbb955c700a6414fd48ae147986e9b42c0508c8a766cea61e7e3badf0f7dde HTTP/1.1
User-Agent: curl/7.29.0
Host: localhost:5000
Accept: /
Content-type: application/octet-stream
Content-Length: 13824
Expect: 100-continue

  • Done waiting for 100-continue
    < HTTP/1.1 400 Bad Request
    < Content-Type: application/json; charset=utf-8
    < Docker-Distribution-Api-Version: registry/2.0
    < Date: Tue, 27 Oct 2015 22:29:02 GMT
    < Content-Length: 131
  • HTTP error before end of send, stop sending
    <
    {“errors”:[{“code”:“DIGEST_INVALID”,“message”:“provided digest did not match uploaded content”,“detail”:“digest parsing failed”}]}
  • Closing connection 0

Also, I am using sha256sum as follows:
$ sha256sum /tmp/hello-world.tar
97bbb955c700a6414fd48ae147986e9b42c0508c8a766cea61e7e3badf0f7dde /tmp/hello-world.tar

What I am possibly doing wrong here? How to get around DIGEST_INVALID error?