问题原文
原帖链接 · dflemstr · CC BY-SA 3.0
I want to be able to inspect the contents of a Docker container (read-only). An elegant way of doing this would be to mount the container's contents in a directory. I'm talking about mounting the contents of a container on the host, not about mounting a folder on the host inside a container.
I can see that there are two storage drivers in Docker right now: aufs and btrfs. My own Docker install uses btrfs, and browsing to /var/lib/docker/btrfs/subvolumes shows me one directory per Docker container on the system. This is however an implementation detail of Docker and it feels wrong to mount --bind these directories somewhere else.
Is there a proper way of doing this, or do I need to patch Docker to support these kinds of mounts?
社区高分解答
原帖链接 · laktak · CC BY-SA 4.0
Take a look at docker export.
To quickly list the files in your container:
docker export CONTAINER|tar -t
To export:
docker export CONTAINER>snapshot.tar
docker export CONTAINER|tar x PATH-IN-CONTAINER
Or to look at a file:
docker export CONTAINER|tar x --to-stdout PATH-IN-CONTAINER
# e.g.
docker export consul|tar x --to-stdout etc/profile
Docker 1.8 supports cp:
https://docs.docker.com/engine/reference/commandline/cp/
Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
update: you should ssh to your docker machine when you run this.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
