用于运行Java程序的DockerFile8金钱.anslist{background:url(source/plugin
技术问答
467 人阅读
|
0 人回复
|
2023-09-11
|
我是Docker的新手,正在尝试从头开始编写新映像。我正在编写此dockerFile来编译和运行同一目录中可用的简单Java程序。这里是dockerfile。7 ^3 j6 o$ l- Z9 Y5 u, ?" F- _
- FROM scratch, _0 z$ {' ~3 u
- CMD javac HelloWorld.javaCMD java HelloWorld
" g6 q( J; _, j" g A Docker构建成功,如下所示, e+ x5 [) p# T6 Y r3 N
- [root@hadoop01 myjavadir]# docker build -t runhelloworld .5 _7 F% L) ^ b4 J* z7 O
- Sending build context to Docker daemon 3.072 kB
8 w8 b2 a* O g: h" P7 X* ` - Sending build context to Docker daemon
6 r6 J2 Q( c* n3 J - Step 0 : FROM scratch
/ g" y1 U4 J G3 Y - --->
) m/ h8 C8 [0 Z6 T - Step 1 : CMD javac HelloWorld.java/ y% o7 a) z9 U) ^8 j8 m
- ---> Running in 7298ad7e902f
* o. a2 c: ]$ I: b- f$ x/ L8 p7 [8 N - ---> f5278ae25f0c
4 b9 G$ s. o5 P - Removing intermediate container 7298ad7e902f
4 q3 [* F, i7 ^- Z' G* T& N+ {' U - Step 2 : CMD java HelloWorld
# F0 i2 E" m, c T% Q - ---> Running in 0fa2151dc7b0
1 }6 N$ N1 J+ R - ---> 25453e89b3f0) E: e3 J2 ]% r, y1 Q) S' V
- Removing intermediate container 0fa2151dc7b0Successfully built 25453e89b3f0
% o1 x% D& r- U. C. y) U 但是当我尝试运行时,它会引发以下错误:
. `" ^% K5 o1 o* g$ O- [root@hadoop01 myjavadir]# docker run runhelloworld$ G6 P# T1 z; Q0 x' H' t+ X, z
- exec: "/bin/sh": stat /bin/sh: no such file or directory1 |. w f. d/ B/ O
- Error response from daemon: Cannot start container 676717677d3f1bf3b0b000d68b60c32826939b8c6ec1b5f2e9876969c60e22a4: [8] System error: exec: "/bin/sh": stat /bin/sh: no such file or directory
$ W1 L# t6 t7 n: [$ T7 a9 _% e - [root@hadoop01 myjavadir]# exec: "/bin/sh": stat /bin/sh: no such file or directorybash: exec:: command not found
, M. e* p# z8 j 请帮助解决相同问题。3 K6 \* x7 Z# _3 Z; y8 z
我知道答案 回答被采纳将会获得8 金钱 已有0人回答 |
|
|
|
|
|