简体   繁体   English

Windows主机中docker windows容器的真实位置?

[英]Real location of docker windows container in a windows host?

Question


I would like to know the location of the containers when it comes to a Windows environment (both the container and the host), that is, I would like to know where the container data is after the command: `docker run...` 我想知道在Windows环境(容器和主机)中容器的位置,也就是说,我想知道在命令之后容器数据在哪里:`docker run ...`

Linux containers can be accessed via \\wsl.localhost\docker-desktop-data , but what about windows containers ? Linux 容器可以通过\\wsl.localhost\docker-desktop-data访问,但是Windows 容器呢?

That said, it is worth mentioning that both the environment and the container are windows, so I also activated the Switch to Windows container option (in Docker)也就是说,值得一提的是,环境和容器都是windows,所以我也激活了Switch to Windows container选项(在Docker中)

Remarks评论


My intention is to copy the data from the container, not the image. 我的意图是从容器中复制数据,而不是图像。

That is, if there are 1000 files located in C:\Folder in Container A , I want to migrate this Container A containing not only the C:\Folder but all its contents to another host .也就是说,如果Container A中的C:\Folder中有 1000 个文件,我想这个Container A不仅包含 C:\Folder 还包含其所有内容迁移到另一个主机

From what I understand, a container has isolated files, this means that I can have another container with the same filenames but with different contents.据我了解,一个容器具有隔离文件,这意味着我可以拥有另一个具有相同文件名但内容不同的容器。

I want to access the files to perform the migration.我想访问文件以执行迁移。

Similar Questions类似问题
Keyword关键词 Theme主题 URL网址
Windows container location Windows 容器位置 This is pretty much the same question as mine.这和我的问题差不多。 Docker Virtual Hard Disk Location Docker 虚拟硬盘位置
Windows container location Windows 容器位置 If it differs from my question because it deals with answers that point to the Linux environment, not Windows如果它与我的问题不同,因为它处理的答案指向 Linux 环境,而不是 Windows Where are Docker images stored on the host machine? Docker 镜像存储在主机的什么位置?

Justification理由


  • Move the windows container to another host machine.将 windows 容器移动到另一台主机。
  • Replacing essential Windows files that can only be modified after having the partitions mounted, ie Windows needs to be turned off (it would be similar to accessing data from an external hard drive)替换只能在挂载分区后才能修改的基本 Windows 文件,即需要关闭 Windows(这类似于从外部硬盘驱动器访问数据)
  • For study reasons出于学习原因

My Environment: 我的环境:

在此处输入图像描述

I understand why you are asking this, but containers are a bit different than VMs.我明白你为什么要问这个,但容器与 VM 有点不同。 With VMs, you have a virtual disk that represents the virtual hard drive for the VM.对于 VM,您有一个虚拟磁盘代表 VM 的虚拟硬盘驱动器。 With containers, what you have are layers that combined represent the container image, which is then used to build new container instances.对于容器,您所拥有的是组合起来代表容器图像的层,然后用于构建新的容器实例。 The container image layers are stored, by default, on the C:\ProgramData folder.默认情况下,容器图像层存储在 C:\ProgramData 文件夹中。 You can change that via the Docker CLI (not sure on Docker Desktop, it should be possible).您可以通过 Docker CLI 更改它(在 Docker Desktop 上不确定,应该可以)。

Now, to your specific question:现在,针对您的具体问题:

  • If you want to move container images from one machine to another, the best alternative is to push the image to a registry (such as Docker Hub) to then pull it on another machine.如果您想将容器镜像从一台机器移动到另一台机器,最好的替代方法是将镜像推送到注册表(例如 Docker Hub),然后将其拉到另一台机器上。 Alternatively, you could rebuild your dockerfile on the other machine (might require other assets, such as the app folder, etc.)或者,您可以在另一台机器上重建您的 dockerfile(可能需要其他资产,例如应用程序文件夹等)

  • If the goal is to change the Windows config, you should do that via dockerfile, not changing the config directly from the folder structure.如果目标是更改 Windows 配置,您应该通过 dockerfile 来完成,而不是直接从文件夹结构更改配置。 This is another main difference from VMs to containers.这是从 VM 到容器的另一个主要区别。 By changing the dockerfile, you make this reproducible, and avoids any issues with the Windows runtime.通过更改 dockerfile,您可以重现它,并避免 Windows 运行时出现任何问题。

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

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