简体   繁体   English

Windows 10 上的 Docker:如何将现有容器和图像移动到新位置?

[英]Docker on Windows 10: How to move existing containers & images to new location?

I want to move my Docker containers & images from C: to elsewhere.我想将我的 Docker 容器和图像从 C: 移动到其他地方。 All containers/images are Windows-ones.所有容器/映像都是 Windows 的。

I've changed the Docker data files location using the data-root configuration option, restarted the daemon and desktop client, and verified the data root location with docker info .我已经使用data-root配置选项更改了 Docker 数据文件位置,重新启动了守护程序和桌面客户端,并使用docker info验证了数据根位置。

The problem is, that none of the existing containers & images are moved to the new location.问题是,现有的容器和图像都没有移动到新位置。 Just the desktop client's configuration files.只是桌面客户端的配置文件。 The desktop client doesn't seem to offer any means for (forcing/persuading it) moving the data to new location.桌面客户端似乎没有提供任何(强制/说服)将数据移动到新位置的方法。

Tried to address the issue by manually copying C:\\ProgramData\\Docker contents to the new location, but everything sooner or later fails when copying special system files, such as bootmgr , inside images in windowsfilter (Running robocopy in elevated PowerShell or copying in Explorer, doesn't matter).试图通过手动将C:\\ProgramData\\Docker内容复制到新位置来解决该问题,但是在复制特殊系统文件(例如bootmgrwindowsfilter图像时,一切迟早都会失败(在提升的 PowerShell 中运行robocopy或在资源管理器中复制,无所谓)。

Is there any way around this, to move existing images & containers without breaking everything?有没有办法解决这个问题,在不破坏一切的情况下移动现有的图像和容器? I don't have a Linux machine at my disposal I could use to mount the NTFS volumes and do the copying there.我没有可用于安装 NTFS 卷并在那里进行复制的 Linux 机器。

I found that setting data-root would result in new images being created on the desired drive but existing images would continue to run from the system drive (C:\\).我发现设置data-root会导致在所需驱动器上创建图像,但现有图像将继续从系统驱动器 (C:\\) 运行。 I even tried deleting the windowsfilter folder on the C:\\ drive but when running the container the images were re-downloaded to the C:\\ drive instead of the configured data-root location.我什至尝试删除 C:\\ 驱动器上的 windowsfilter 文件夹,但是在运行容器时,图像被重新下载到 C:\\ 驱动器而不是配置的数据根位置。

The thing that worked for me was to perform a factory reset from the troubleshooting menu (The对我有用的是从故障排除菜单中执行恢复出厂设置( 错误图标 in docker desktop is a shortcut to this menu).在 docker desktop 中是此菜单的快捷方式)。 This will clean up the windowsfilter folder in your system drive - However I had to run factory reset twice as the first time failed.这将清理系统驱动器中的 windowsfilter 文件夹 - 但是,由于第一次失败,我不得不两次恢复出厂设置。

After reset has completed, go to Settings->Docker Engine and add a data-root entry folder on another drive:重置完成后,转到Settings->Docker Engine并在另一个驱动器上添加一个data-root条目文件夹:

{
  "registry-mirrors": [],
  "insecure-registries": [],
  "debug": false,
  "experimental": false,           <-- remember to add a comma here
  "data-root": "E:\\dockerdata"
}

Then click Apply & Restart然后点击Apply & Restart

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

相关问题 Docker 镜像和容器位置与 Windows 10 使用 hyper-v - Docker images and containers location with Windows 10 using hyper-v Windows 10 上保存 docker 图像的默认位置 - Default location where docker images are saved on Windows 10 在Windows 10上链接两个Docker容器 - Link two docker containers on Windows 10 哪个Windows 10版本可以运行Docker容器? - which windows 10 edition for running docker containers? Windows 10:Docker 立即退出容器 - Windows 10: Docker exits containers immediately In Docker Desktop for windows 10 with WSL2, where does docker containers live &amp; how Linux containers can run a java app, but not windows nanoserver? - In Docker Desktop for windows 10 with WSL2, where does docker containers live & how Linux containers can run a java app, but not windows nanoserver? Docker 容器在 Windows 10 中的真实位置在哪里? - Where is Docker container real location in Windows 10? 为什么删除 docker 容器和图像不会释放 Windows 上的存储空间? 如何解决? - Why removing docker containers and images does not free up storage space on Windows? How to fix it? Docker 在哪里存储 Windows 10 上的图像文件? - Where Docker stores files of images on Windows 10? docker 和Windows一起使用时,镜像和容器存储在哪里? - Where are docker images and containers stored when we use it with Windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM