Receiving 'failed to copy directory: invalid symlink' on COPY command

In my Dockerfile, when I get to this build step:

COPY ./API/. /app/API

I receive this error:
ERROR: Service 'portal' failed to build: failed to copy files: failed to copy directory: invalid symlink "\\\\?\\Volume{45afd2d1-b8ce-4ce7-9ec2-f39bcad96f75}\\app\\API\\ClientApp" -> "..\\Web"**

In the API folder I have a symlink that links the API/ClientApp folder to the app/Web folder. In the API folder there is a .NET Core application using single page application (SPA) and the SPA root is set to

My folder structure is like this:

-root \
   - API \
   - Web \

How would I solve the error? Do I need to change the SPA root path somehow?

What I’m using;
Docker engine 19.03.8
Windows 10 Version 1909
Docker Desktop

I’ve read a few articles about this issue … seems NTFS doesn’t support symlinks:

Native NTFS does not support symlinks. These are emulated with WSL by setting some file attribute (I think) and then add the target of the link in the file. CIFS/SMB on linux does something similar for emulating symlinks (see here), so does cygwin, as far as I know. MinGW handles symlinks different again.

Due to these different approaches we can only support symlinks created within containers. These then are resolvable in other containers but not on the host (and vice versa).

Unfortunately, I will have to close this as won’t fix

So I highly suggest you to switch to Linux !
Also you may have a look at this: Symlinks on shared volumes not supported

Thanks for the reply. NTFS does support symlinks it just in a different way than Linux: The symlink is needed for some custom authentication, plus the app in production runs on a Windows Server. Is there a way where I could recreate the symlink in the Dockerfile?

Again, I’m not sure what windows will make out of it …

Try creating symlinks in you Dockerfile:

RUN ln -s mySourceFile myTargetFile

I tried using the windows equivalent of ln in the dockerfile but got an Invalid switch - "API". error.

RUN mklink /j app/API/ClientApp /app/Web

I’m going to do some more research. Thanks for your help.