Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dockerfile with windows path

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 ?

like image 422
darkomen Avatar asked Sep 23 '16 15:09

darkomen


People also ask

Where is docker path in Windows?

By default, Docker Desktop is installed at the following location: On Mac: /Applications/Docker. app. On Windows: C:\Program Files\Docker\Docker.

What is path in Dockerfile?

The docker build command builds an image from a Dockerfile and a context. The build's context is the set of files at a specified location PATH or URL . The PATH is a directory on your local filesystem. The URL is a Git repository location. The build context is processed recursively.

Can I have ENTRYPOINT and CMD in Dockerfile?

#6 Using ENTRYPOINT with CMD Still, they both can be used in your Docker file. There are many such cases where we can use both ENTRYPOINT and CMD. The thing is that you will have to define the executable with the ENTRYPOINT and the default parameters using the CMD command. Maintain them in exec form at all times.

How do I change the location of docker images in Windows?

There is an easier way to do this: Go to Docker Settings > Advanced > Change "Disk image location" and click "Apply" when prompted. Docker engine will shut down the VM and move it for you to the new location.


1 Answers

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:\
like image 93
BMitch Avatar answered Sep 21 '22 16:09

BMitch