हाय मैं डॉकर के लिए नया हूं और स्क्रैच से एक नई छवि लिखने की कोशिश कर रहा हूं। मैं इस डॉकरफ़ाइल को एक ही निर्देशिका में उपलब्ध एक सरल जावा प्रोग्राम को संकलित और चलाने के लिए लिख रहा हूं।एक जावा प्रोग्राम चलाने के लिए डॉकरफ़ाइल
यहां डॉकरफ़ाइल है।
FROM scratch
CMD javac HelloWorld.java
CMD java HelloWorld
डोकर निर्माण सफल हुआ नीचे के रूप में
[[email protected] myjavadir]# docker build -t runhelloworld .
Sending build context to Docker daemon 3.072 kB
Sending build context to Docker daemon
Step 0 : FROM scratch
--->
Step 1 : CMD javac HelloWorld.java
---> Running in 7298ad7e902f
---> f5278ae25f0c
Removing intermediate container 7298ad7e902f
Step 2 : CMD java HelloWorld
---> Running in 0fa2151dc7b0
---> 25453e89b3f0
Removing intermediate container 0fa2151dc7b0
Successfully built 25453e89b3f0
दिखाया लेकिन जब मैं चलाने का प्रयास है, यह निम्न त्रुटि फेंकता है:
[[email protected] myjavadir]# docker run runhelloworld
exec: "/bin/sh": stat /bin/sh: no such file or directory
Error response from daemon: Cannot start container 676717677d3f1bf3b0b000d68b60c32826939b8c6ec1b5f2e9876969c60e22a4: [8] System error: exec: "/bin/sh": stat /bin/sh: no such file or directory
[[email protected] myjavadir]# exec: "/bin/sh": stat /bin/sh: no such file or directory
bash: exec:: command not found
कृपया एक ही हल करने में मदद।
RUN
पर दूसरी पंक्ति चैन करने के बाद अद्यतन करें।
[[email protected] myjavadir]# docker build -t runhelloworld .
Sending build context to Docker daemon 3.584 kB
Sending build context to Docker daemon
Step 0 : FROM scratch
--->
Step 1 : RUN javac HelloWorld.java
---> Running in fdef2d65ac58
exec: "/bin/sh": stat /bin/sh: no such file or directory [8]
System error: exec: "/bin/sh": stat /bin/sh: no such file or directory
आप, जावा से बजाय खरोंच से कोशिश कर सकते हैं, क्योंकि यह एक जावा आवेदन –
http://stackoverflow.com/questions/31696439/how-to-build-a- चलाने के लिए जावा के न्यूनतम निर्भरता की जरूरत है डॉकर-कंटेनर-फॉर-ए-जावा-ऐप/31710204 # 31710204 –