1

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 ...`

Linux containers can be accessed via \\wsl.localhost\docker-desktop-data, but what about windows containers?

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)

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.

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 This is pretty much the same question as mine. Docker Virtual Hard Disk Location
Windows container location If it differs from my question because it deals with answers that point to the Linux environment, not Windows Where are Docker images stored on the host machine?

Justification


  • Move the windows container to another host machine.
  • Replacing essential Windows files that can only be modified after having the partitions mounted, i.e. Windows needs to be turned off (it would be similar to accessing data from an external hard drive)
  • For study reasons

My Environment:

enter image description here

Lucas Paixão
  • 862
  • 5
  • 11

1 Answers1

1

I understand why you are asking this, but containers are a bit different than VMs. With VMs, you have a virtual disk that represents the virtual hard drive for the 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. You can change that via the Docker CLI (not sure on Docker Desktop, it should be possible).

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. Alternatively, you could rebuild your dockerfile on the other machine (might require other assets, such as the app folder, etc.)

  • If the goal is to change the Windows config, you should do that via dockerfile, not changing the config directly from the folder structure. This is another main difference from VMs to containers. By changing the dockerfile, you make this reproducible, and avoids any issues with the Windows runtime.

  • I have updated the question, please review the "Remarks" section. But what I want is **not** to move the image (which is what was used to create the container) but to **copy the data from the container** – Lucas Paixão Dec 14 '22 at 23:22
  • To clarify: Do you mean, you save something inside the container and then you could access it from outside so you can copy to someplace else? On containers that is also not recommended (or supported). With containers, the recommendation is: If you have to save something (state or data), you should use a persistent volume. A persistent volume can be mounted to multiple containers, so you don't depend on a specific instance. Also, it could be a local folder or a network share, which would make the process of copying the content much easier from outside the container. – Vinicius Apolinario Dec 14 '22 at 23:29
  • Here's a doc explaining what I mentioned above: https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-storage – Vinicius Apolinario Dec 14 '22 at 23:29
  • "Do you mean, you save something inside the container and then you could access it from outside so you can copy to someplace else?" Yes. So does that mean it's currently not supported (impossible) to access container data without using a volume? – Lucas Paixão Dec 14 '22 at 23:39
  • In my next containers I will follow this practice, but I'm currently looking for an efficient way to solve this situation :( – Lucas Paixão Dec 14 '22 at 23:43
  • I'm honestly not aware of a way to access the storage directly from host - again, these are not like VMs. :( One way would be to transfer the content via a network share. You would have to mount a volume to the container anyway to do that. – Vinicius Apolinario Dec 15 '22 at 22:56