如何访问 Docker 容器内容

How do I access a Docker Containers Contents

您可以访问 /var/lib/docker/containers/<container id>/ 下的 docker 个容器,但是您可以在哪里访问它的内容,它们必须存储在服务器上的某个地方吗?

当您创建容器时,您使用 -v server:container_location 或 -v volume_name:container_location

映射卷

您没有提供设置容器的方式。所以,你可以检查

docker inspect CONTAINER_NAME. 

查看映射文件夹 or/and docker 卷

另外,可以在容器中 运行 docker 的机器上执行命令。

docker exec CONTAINER_NAME command 

(例如,您可以 ls 或 bash 进入容器)

一切都取决于容器的创建方式。

you 你提供 docker 运行.. 你使用的字符串。您可能会得到更多帮助。

用于文件检查

you need to specify volume driver options, you must use --mount. -v or --volume: Consists of three fields, separated by colon characters (:). The fields must be in the correct order, and the meaning of each field is not immediately obvious. In the case of named volumes, the first field is the name of the volume, and is unique on a given host machine. For anonymous volumes, the first field is omitted. The second field is the path where the file or directory are mounted in the container. The third field is optional, and is a comma-separated list of options, such as ro. These options are discussed below. --mount: Consists of multiple key-value pairs, separated by commas and each consisting of a = tuple. The --mount syntax is more verbose than -v or --volume, but the order of the keys is not significant, and the value of the flag is easier to understand. The type of the mount, which can be bind, volume, or tmpfs. This topic discusses volumes, so the type is always volume. The source of the mount. For named volumes, this is the name of the volume. For anonymous volumes, this field is omitted. May be specified as source or src. The destination takes as its value the path where the file or directory is mounted in the container. May be specified as destination, dst, or target. The readonly option, if present, causes the bind mount to be mounted into the container as read-only. The volume-opt option, which can be specified more than once, takes a key-value pair consisting of the option name and its value.

https://docs.docker.com/storage/volumes/