Tools, FAQ, Tutorials:
Spaces in Path Name on Windows Images
How to manage spaces in path names on Windows images?
✍: FYIcenter.com
Spaces in path names are not allowed on Linus systems.
But spaces in path names are allowed on Windows systems.
There are 2 general rules you have to remember to manage spaces in path names in the Dockerfile to build Windows images.
1. Using the "shell" format to specify parameters in Dockerfile, if there is no spaces in any parameters. For example:
RUN PowerShell mkdir C:\fyicenter COPY Hello.java C:/fyicenter/Hello.java
2. Using the "exec" format to specify parameters in Dockerfile, if there are spaces in some parameters. For example:
RUN ["PowerShell", "mkdir", "\"C:\\FYI Center\""] COPY ["Hello.java", "C:/FYI Center/Hello.java"]
Notes on using "exec" format:
Here is Dockerfile example, JavaImage, that uses spaces in path names:
C:\fyicenter> type JavaImage FROM openjdk RUN ["PowerShell", "mkdir", "\"C:\\FYI Center\""] COPY ["Hello.java", "C:/FYI Center/Hello.java"] RUN ["javac", "C:\\FYI Center\\Hello.java"] ENTRYPOINT ["java", "-cp", "C:\\FYI Center", "Hello"]
Build and run it.
C:\fyicenter> docker build --file JavaImage --tag myjava . Step 1/5 : FROM openjdk ---> fdc7d8d04bc9 Step 2/5 : RUN ["PowerShell", "mkdir", "\"C:\\My Home\""] ---> Running in 0e457fcd1025 Removing intermediate container 0e457fcd1025 ---> d3757bcbd35f Step 3/5 : COPY ["Hello.java", "C:/My Home/Hello.java"] ---> 3937cb41e4cf Step 4/5 : RUN ["javac", "C:\\My Home\\Hello.java"] ---> Running in 5f0dcbe06a8d Removing intermediate container 5f0dcbe06a8d ---> a30f5dd0735a Step 5/5 : ENTRYPOINT ["java", "-cp", "C:\\My Home", "Hello"] ---> Running in ce414d3bfad3 Removing intermediate container ce414d3bfad3 ---> 2bffa2d267d3 Successfully built 2bffa2d267d3 Successfully tagged myjava:latest C:\fyicenter> docker run --name myjava myjava Hello world! C:\fyicenter> docker rm myjava myjava
Ok, we are able to build our own Java Docker image with a Java program in sub-directory that has a space in the path name.
⇒ "shell" Format vs. "exec" Format
⇐ Path Name Used to Build Windows Images
2021-11-30, 1040🔥, 0💬
Popular Posts:
What is Azure API Management Publisher Dashboard? Azure API Management Publisher Dashboard is an Azu...
FYIcenter JSON Validator and Formatter is an online tool that checks for syntax errors of JSON text ...
What is EPUB 2.0 Metadata "dc:creator" and "dc:contributor" elements? EPUB 2.0 Metadata "dc:creator"...
How to use .NET CLR Types in Azure API Policy? By default, Azure imports many basic .NET CLR (Common...
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...