如何编辑现有的docker图像元数据? [英] How can I edit an existing docker image metadata?

查看:231
本文介绍了如何编辑现有的docker图像元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于以下原因,我要编辑docker图像元数据:

I would like to edit a docker images metadata for the following reasons:

  • 我不喜欢图像父母EXPOSE,VOLUME等声明(请参阅# 3465 ,Docker-Team不想提供解决方案),所以我想取消体积"或不暴露"图像.

  • I don't like an image parents EXPOSE, VOLUME etc declaration (see #3465, Docker-Team did not want to provide a solution), so I'd like to "un-volume" or "un-expose" the image.

我不喜欢图像ContainerConfig(请参阅docker inspect [image]),因为它是使用docker commit [container]

I dont't like an image ContainerConfig (see docker inspect [image]) cause it was generated from a running container using docker commit [container]

docker builddocker run期间修复错误,例如:
cannot mount volume over existing file, file exists [path]

Fix error durring docker build or docker run like:
cannot mount volume over existing file, file exists [path]

有什么办法可以做到吗?

Is there any way I can do that?

推荐答案

虽然有点黑,但可以:

  1. 将图像保存到tar.gz文件:
    $ docker save [image] > [targetfile.tar.gz]

  1. Save the image to a tar.gz file:
    $ docker save [image] > [targetfile.tar.gz]

提取tar文件以访问原始图像数据:
tar -xvzf [targetfile.tar.gz]

Extract the tar file to get access to the raw image data:
tar -xvzf [targetfile.tar.gz]

manifest.json文件中查找图像元数据文件:应该有一个像.Config这样的键,其中包含一个[HEX]数字.提取的文件夹的根目录中应该有一个精确的[HEX].json.
这是包含图像元数据的文件.根据需要进行编辑.

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.

将提取的文件打包回new.tar.gz存档

Pack the extracted files back into an new.tar.gz-archive

使用cat [new.tar.tz] | docker load重新导入修改后的图像

Use cat [new.tar.tz] | docker load to re-import the modified image

使用docker inspect [image]验证您的元数据更改已应用

Use docker inspect [image] to verify your metadata changes have been applied

这篇关于如何编辑现有的docker图像元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆