I want to download image as a blob or tar from Docker, to push somewhere as a file. Using docker-registry-client in NodeJS with method createBlobReadStream, somwhow take blob file but it is only conf file of image.
async function createReadStream(DIGEST) {
client.createBlobReadStream({ digest: DIGEST }, function (err, stream) {
if (err) {
console.log(err)
client.close();
return
}
console.log('Got a digest %s', DIGEST);
var fout = fs.createWriteStream(`//wsl$//docker-desktop-data//version-pack-data//community//docker//image//overlay2//imagedb//content//sha256//blob-${DIGEST}.file`);
fout.on('finish', function () {
console.log('Done downloading blob', DIGEST);
});
fout.on('error', function (err) {
console.log(err)
})
stream.pipe(fout);
stream.resume();
client.close();
})
}
There is addittional things I should mention:
- All actions done in Windows 10, Docker with Linux containers
- NodeJS as platform and docker-registry-client as library.
- Docker data stores in ext4.vhdx
Where to extract blob or tar of just created Docker image with NodeJS?
docker image pull my_image:my_tag && docker image save my_image:my_tag -o my_image-my_tag.tar. Doing this through you above api will require much more than a single simple blob download (get manifest, parse all layers, get them individually, package the result....). Is it really worth re-implementing a full docker client you already have if saving an image content is your only requirement? - ZeitounatorDo you know how to do it in NodeJS?<= no but I basically gave you the global recipe in my very first comment. - Zeitounator