How to make Dockerfile COPY work for windows absolute paths?

Viewed 2351

How do I make my COPY command work for absolute paths on Windows? I tried git-bash, cmd and powershell consoles to build with docker build -t custom-maven-image .

# Dockerfile
FROM maven:3-openjdk-11-slim
# these are three versions of copy command I tried
COPY C:/Users/myuser/.m2 /root/.m2
COPY /C/Users/myuser/.m2 /root/.m2
COPY /c/Users/myuser/.m2 /root/.m2

What I get is an error:

...
#5 ERROR: "/C/Users/myuser/.m2" not found: not found

UPDATE:

Thx @Jeremy for bugs references and now I see that docs clearly says:

COPY obeys the following rules:

The path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.

1 Answers
Related