Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Docker Copies files to windows?

i have a base windows image and want to change one of the assemblies in app's bin folder.

FROM baseImage
COPY ./files/ ./Application/bin

but i saw two strange behavior in result when navigated to destination path:

  1. if source files are existed in destination, files overwrote in uppercase filenames!
  2. if source files are not existed the files are copied as the source's filename capital convention!

File in source: A.B.C.dll

After copy to destination: a.b.c.dll (A.B.C.dll existed)

Another File in source: D.E.F.dll

After copy to destination: D.E.F.dll (D.E.F.dll not existed)

have an explanation about this behavior?

however these behavior is not my big problem my problem is some mistake when my app's framework wants to register my types in dlls but when framework wants to load newly overwritten files it throws exception that it is already loaded! discovering about this problem, I confused about this Docker COPY behavior.

Additional Info:


I tired docker cp and overwrote existing file. it still copies and overwrite files in lowercase filename. when change them to true format all things goes fix. is it something about NTFS options and out of docker boundry? i use Windows Server 2019

like image 270
Mehdi Avatar asked Sep 29 '19 11:09

Mehdi


People also ask

How do I copy a file from a docker container to Windows?

To summarize, follow these steps to copy a file from a Docker container to a host machine: Obtain the name or id of the Docker container. Issue the docker cp command and reference the container name or id. The first parameter of the docker copy command is the path to the file inside the container.

How does copy work in docker?

COPY is a docker file command that copies files from a local source location to a destination in the Docker container. ADD command is used to copy files/directories into a Docker image. It only has only one assigned function. It can also copy files from a URL.


1 Answers

This is a limitation in Windows not Docker, (See: https://github.com/docker/for-win/issues/1155).

The issue referenced above provides this Microsoft Developer Blog on Windows Subsystem for Linux (WSL), and Case Sensitivity which states the following:

Since Windows applications treat the file system as case insensitive, they cannot distinguish between files whose names only differ in case...The Windows NT family of operating systems (including Windows 10) has always had the ability to perform case sensitive file system operations...However, for compatibility reasons, there is a global registry key that overrides this behavior; when this key is set, all file operations are case insensitive...Since Windows XP, this has been the default.

Basically, it really does not matter which file system is in use, rather this is due to the operating system itself.

like image 63
oxr463 Avatar answered Oct 07 '22 19:10

oxr463