我可以从我的本地访问在 Docker Container 中创建的一些文件吗?(例如 C 驱动器或桌面文件夹)

Can I access some files which created in Docker Container from my local?(ex C drive or Desktop Folder)

我有 window10 和 SSD(例如 samsung SSD 256G)

如果我创建了一个 Docker ubuntu 容器并访问其中的某处(例如 /home/myname)
我创建了包含“hello world”的 test.txt,它可能位于“/home/myname/test.txt”
test.txt 可能有自己的大小 (8kb) 我认为它应该从 samsung.SSD

得到他的房间

我可以使用 'docker attach' 访问 test.txt 而且我知道如何使用 -v 选项安装然后我可以更改或更新该文件(我知道它只是从容器中复制的)

但我想从我的 Window10 C 盘或 window10-Desktop 查看或访问 test.txt 文件,或者使用 window10 提供的 find/search 函数 test.txt 是如何存在的,或者使用我的 samsung.SSD

抱歉缺少基本的计算系统。

以下内容来自“https://docs.docker.com/storage/”,它对我来说不够用

By default all files created inside a container are stored on a writable container layer. This means that:

The data doesn’t persist when that container no longer exists, and it can be difficult to get the data out of the container if another process needs it.
A container’s writable layer is tightly coupled to the host machine where the container is running. You can’t easily move the data somewhere else.
Writing into a container’s writable layer requires a storage driver to manage the filesystem. The storage driver provides a union filesystem, using the Linux kernel. This extra abstraction reduces performance as compared to using data volumes, which write directly to the host filesystem.
Docker has two options for containers to store files in the host machine, so that the files are persisted even after the container stops: volumes, and bind mounts. If you’re running Docker on Linux you can also use a tmpfs mount. If you’re running Docker on Windows you can also use a named pipe.

Keep reading for more information about these two ways of persisting data.

看来您不了解 -v 的工作原理

$ docker run -ti --rm -v "<your_windows_path>:/apps -w /apps ubuntu bash
root@b2fd40f5f423:/apps# echo "helloworld" > test.txt

-w /apps (WORKDIR) 以确保您在容器中创建的文件将与反映到您的 windows 路径的路径相同。

从您的 windows 系统,您应该可以在本地磁盘或 SSD 磁盘路径 <your_windows_path>

下搜索此文件

试试这里的建议:

认为这是一个两步过程,也许您错过了第一步。