Failing miserably to setup Minio as Backblaze B2 storage for Docker Registry

December 1, 2017    devops docker

Yes, today I failed miserably to setup a Docker Registry server backed by Backblaze B2 using Minio’s B2 Gateway.

Here’s the result:

The push refers to a repository [localhost:5000/myfirstimage]
2f5b0990636a: Pushing [==================================================>]  3.072kB
c9748fbf541d: Retrying in 3 seconds
b3968bc26fbd: Pushing  14.85kB
aa4e47c45116: Retrying in 7 seconds
788ce2310e2f: Retrying in 1 second
received unexpected HTTP status: 500 Internal Server Error

It gets stucked uploading forever, trying and retrying to perform operations such as CopyObjectPart through Minio that Backblaze B2 will probably never implement. This is a known limitation of Minio Gateway for B2 and it’s one of the operations required by the docker registry.

Here’s the log:

time="2017-12-02T02:34:22Z" level=error msg="Unable to perform CopyObjectPart bithavoc-docker-images/docker/registry/v2/repositories/myfirstimage/_uploads/0afe38fa-8d66-4ea6-8c70-4d5e9664402a/data" cause="Not Implemented" source="[object-handlers.go:793:objectAPIHandlers.CopyObjectPartHandler()]" stack="gateway-b2.go:603:(*b2Objects).CopyObjectPart object-handlers.go:791:objectAPIHandlers.CopyObjectPartHandler api-router.go:47:(objectAPIHandlers).CopyObjectPartHandler-fm"
time="2017-12-02T02:34:22Z" level=error msg="Unable to complete multipart upload." cause="b2_finish_large_file: 400: bad_json: large files must have at least 2 parts" source="[object-handlers.go:1067:objectAPIHandlers.CompleteMultipartUploadHandler()]" stack="gateway-b2.go:694:(*b2Objects).CompleteMultipartUpload object-handlers.go:1065:objectAPIHandlers.CompleteMultipartUploadHandler api-router.go:53:(objectAPIHandlers).CompleteMultipartUploadHandler-fm"

In case you want to try it yourself, you just need to replace your real B2 <b2-secret-key> and <b2-secret-key> in the following commands:

Create a Docker Network

docker network create --driver bridge minio_registry_nw

Start Minio

docker run -p 9725:9725 -e MINIO_ACCESS_KEY=<b2-access-key> -e MINIO_SECRET_KEY=<b2-secret-key> --name minio --network minio_registry_nw minio/minio gateway b2 --address 0.0.0.0:9725

Start Registry

docker run -d -p 5000:5000 -e REGISTRY_STORAGE_S3_REGION=us-east-1 -e REGISTRY_STORAGE_S3_BUCKET=bithavoc-docker-images -e REGISTRY_STORAGE_S3_REGIONENDPOINT=minio:9725 -e REGISTRY_STORAGE_S3_SECURE=false -e REGISTRY_STORAGE_S3_ACCESSKEY=<b2-access-key> -e REGISTRY_STORAGE_S3_SECRETKEY=<b2-secret-key> -e REGISTRY_STORAGE=s3 --name registry --network minio_registry_nw registry:2

Faily miserably to upload images :)

docker push localhost:5000/myfirstimage