How can I edit an existing docker image metadata?
Its a bit hacky, but works:
Save the image to a tar.gz file:
$ docker save [image] > [targetfile.tar.gz]
Extract the tar file to get access to the raw image data:
tar -xvzf [targetfile.tar.gz]
Lookup the image metadata file in the
manifest.json
file: There should be a key like.Config
which contains a[HEX]
number. There should be an exact[HEX].json
in the root of the extracted folder.
This is the file containing the image metadata. Edit as you like.Pack the extracted files back into an
new.tar.gz
-archiveUse
cat [new.tar.gz] | docker load
to re-import the modified imageUse
docker inspect [image]
to verify your metadata changes have been applied
I had come across the same workaround - since I have to edit the metadata of some images quite often (fixing an automated image rebuild from a third party), I have create a little script to help with the steps of save/unpack/edit/load.
Have a look at docker-copyedit. It can remove or overrides volumes as well as set other metadata values like entrypoint and cmd.