dockerfile with windows path
Use a relative path (not fully qualified with c:\, but relative to the build directory) and switch to forward slashes:
COPY scripts/base.sh /home/docker/scripts/base.sh
When you do a docker build -t myimg:latest .
, the last .
tells the docker client to send the current directory (excluding anything listed in .dockerignore
) to the docker engine to do the build. Anything not included in that directory cannot be included with a COPY
or ADD
command. The standard process is to place your Dockerfile and all needed dependencies in a single folder, and do your build inside that folder.
Also note that 1.12 added the ability to change the escape character from the backslash that Linux/Unix uses to a backtick. This is defined in a special escape directive at the top of your Dockerfile, prefixed with a #
. I wouldn't recommend doing this with images you're building for Linux hosts:
# escape=`
# Example Dockerfile with escape character changed
FROM windowsservercore
COPY testfile.txt c:\
RUN dir c:\
Related videos on Youtube
Comments
-
darkomen almost 2 years
I would like to launch COPY command dockerfile for build image docker with copy bash file from host(windows 10) to ubuntu image like this :
COPY "C:\toto\directory_good\base.sh" /home/docker/scripts/base.sh
I try a lot of possibility but I always have the same error message :
lstat C:\base.sh: no such file or directory
I want to provisionning and configurate my container docker with some few bash file in my windows 10 OS.
What is the correct way to write path windows in Dockerfile. Do you have a example for more understand howto this ?