Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sreekesh93/a3a181496010c7200af4822c8a3b1ca1 to your computer and use it in GitHub Desktop.
Save sreekesh93/a3a181496010c7200af4822c8a3b1ca1 to your computer and use it in GitHub Desktop.
Upload images to docker registry using api #docker-api #registry #upload image

Uploading docker images using docker-registry api(golang)

Steps to upload docker image:

  • Docker image can be saved onto disk using

docker save -o {FILE-PATH} {DOCKER-IMAGE-NAME}:{DOCKER-IMAGE-TAG}

  • The saved file is a tar archive. The contents (of interest) within the saved docker tar file are:
    • manifest.json
    • A config json with file name based on sha256 of its contents.
    • Layer folders with tar files(layer.tar).
  • A sample manifest json looks like:(filename: manifest.json) manifest.json
  • The Layers array represents the relative paths of constituent layers that needs to be uploaded as blobs using docker-registry api.
  • It should be noted that the digest of each layer are also available within the Config json file as : (filename: fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e.json) config.json
  • Here the value “sha256:af0b15c8625bb1938f1d7b17081031f649fd14e6b233688eea3c5483994a66a3” represents the digest of the layer "cdccdf50922d90e847e097347de49119be0f17c18b4a2d98da9919fa5884479d/layer.tar" from manifest.json.
  • For uploading the docker image, one should upload all layers with its respective digests from paths mentioned above.
  • This can be done using the BlobStore api of docker-registry.
  • Once the blobs(with the digests are uploaded) the config json( in this case “fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e.json”) can be uploaded using Manifest service of docker-registry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment