简体   繁体   English

我如何安装docker容器文件系统?

[英]How would I mount docker container filesystem?

How would I mount docker container images so that I could modify them with external tools ? 我如何安装docker容器图像,以便我可以使用外部工具修改它们?

This means: from the docker hosts, mounting the image without launching a container on it, as a normal filesystem. 这意味着:从docker主机,安装映像而不在其上启动容器,作为普通文件系统。 I should'nt need to run a container for this. 我不应该为此运行一个容器。

I'd like to update the image directly this way, then probably send something like docker commit . 我想以这种方式直接更新图像,然后可能发送像docker commit这样的东西。 With lxc tools (in ubuntu for example) its quite easy as it is directly available to host in /var/lib/lxc/MYCONTAINER/rootfs . 使用lxc工具(例如在ubuntu中)非常简单,因为它可以直接在/var/lib/lxc/MYCONTAINER/rootfs

I know about workarounds, but: 我知道解决方法,但是:

  • I don't feel that using Dockerfile context (and ADD ) is rather convenient nor adapted: I don't have a specific directory to send, but rather would use a combination of tools to change only specific files (think of rsync for instance). 我不认为使用Dockerfile上下文(和ADD )相当方便也不适应:我没有要发送的特定目录,而是使用工具组合来仅更改特定文件(例如,考虑rsync ) 。
  • Even if ADD contains some sort of algorithm that only adds new files to the image appropriately, I still have to send all files as docker context for the build command !. 即使ADD包含某种只适当地向图像添加新文件的算法,我仍然必须将所有文件作为docker context发送给build命令!
  • I could update the container image by calling tools pre-installed in the image. 我可以通过调用图像中预先安装的工具来更新容器图像。 But apt-get install git on a debian image doubles the size of the image. debian图像上的apt-get install git会使图像的大小翻倍。 And git won't be used in production. git不会用于生产。 And removing tools after usage is not always so easy, besides that it feels wrong. 使用后删除工具并不总是那么容易,除了感觉不对外。
  • I could use -v docker build's option to mount a directory full of tools... and their dependencies. 我可以使用-v docker build选项来安装一个充满工具的目录......以及它们的依赖项。 This feels hard if you need more than a very simple bash-script. 如果您需要的不仅仅是一个非常简单的bash脚本,这会让您感到很难受。

在你的情况下,我会运行一个容器(我知道你反对这个)然后,例如rsync文件到/ var / lib / docker / devicemapper / mnt / CONTAINERID / rootfs,然后是docker commit。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM