- Using docker-distribution golang api, we can upload docker images without running docker daemon.
- 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)
- 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)
- 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.