How do I mount the docker container filesystem?

How do I mount docker container images so that I can modify them with external tools?

This means: from the docker hosts, installing the image without running the container on it, just like a normal filesystem. I don't need to start the container for this.

I would like to update the image directly this way and then probably send something like docker commit

. With tools lxc

(like ubuntu) it's pretty easy as it's available to be hosted in /var/lib/lxc/MYCONTAINER/rootfs

.

I know of workarounds, but:

  • I don't feel like using context Dockerfile

    (s ADD

    ) is quite convenient and adaptive: I don't have a dedicated directory to upload, but would rather use a combination of tools to modify only certain files (e.g. rsync

    ).
  • Even if ADD

    contains some kind 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 !.
  • I could update the container image by calling the tools preset on the image. But apt-get install git

    the image debian

    doubles the image size. And git won't be used in production. And removing tools after use isn't always that easy, other than that it doesn't feel right.
  • I could use the -v

    docker build option to mount a directory full of tools ... and their dependencies. It's tricky if you need more than just a bash - script.
+3


source to share


1 answer


In your situation, I would start a container (I know you are against that) and then for example rsync files in / var / lib / docker / devicemapper / mnt / CONTAINERID / rootfs then docker commits.



+1


source







All Articles