I want to write a cmd in docker file to copy the file at the destination C:\windows\Program Files
. I am having an issue due to space in program files. I am able to copy the file to different location. Any suggestion will be appreciated.
I am getting below error:
Step 4 : COPY "C:\docker\prerequisites\MicrosoftSDKs" "C:\Program Files (x86)\MicrosoftSDKs"
Forbidden path outside the build context: C:\docker\prerequisites\MicrosoftSDKs ()
Using the cd Command In Linux, the cd command is the standard way to change the directory for most use cases. On the same note, when working with some docker instructions such as RUN, CMD, and ENTRYPOINT, we can use the cd command to change the directory for the current command in context.
Within the virtual image, the path is the default Docker path /var/lib/docker .
Volumes can be declared in your Dockerfile using the VOLUME statement. This statement declares that a specific path of the container must be mounted to a Docker volume. When you run the container, Docker will create an anonymous volume (volume with a unique id as the name) and mount it to the specified path.
The WORKDIR command is used to define the working directory of a Docker container at any given time. The command is specified in the Dockerfile. Any RUN , CMD , ADD , COPY , or ENTRYPOINT command will be executed in the specified working directory.
Use the JSON form, you have to use double backslashes inside the braces
FROM microsoft/windowsservercore
COPY ["C:\\docker\\prerequisites\\MicrosoftSDKs", "C:\\Program Files (x86)\\MicrosoftSDKs"]
You can also use slash:
COPY ["C:/Program Files/nodejs", "/windows/system32"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With