用于运行Java程序的DockerFile8金钱.anslist{background:url(source/plugin
技术问答
141 人阅读
|
0 人回复
|
2023-09-11
|
我是Docker的新手,正在尝试从头开始编写新映像。我正在编写此dockerFile来编译和运行同一目录中可用的简单Java程序。这里是dockerfile。
! M9 J9 k' `! q, i" Q& x' E* m- FROM scratch. S( e' B0 o' ^8 F
- CMD javac HelloWorld.javaCMD java HelloWorld
) o( A* X/ p. `1 E' L9 F Docker构建成功,如下所示
% w! f9 J+ i( Y& H3 B {# |5 q- [root@hadoop01 myjavadir]# docker build -t runhelloworld ., b) e ~/ ]+ B
- Sending build context to Docker daemon 3.072 kB
( O: d O1 |3 C I6 A$ Y, J2 } - Sending build context to Docker daemon
+ X' U8 r! H/ \: k - Step 0 : FROM scratch
/ S& X5 V5 e* N. z" _: D* c - --->
! D. Z3 R1 s, F0 m9 j. j - Step 1 : CMD javac HelloWorld.java; {. A8 u" D# ]6 C7 g# q6 l
- ---> Running in 7298ad7e902f
$ b7 k( V: I$ q - ---> f5278ae25f0c; d% Y# m: Y, O
- Removing intermediate container 7298ad7e902f
! M% i; T4 k8 A O! M - Step 2 : CMD java HelloWorld9 W' [" ~' Z" P' K) s
- ---> Running in 0fa2151dc7b0
/ }; |; z; H' f! R9 k" w9 s3 M - ---> 25453e89b3f03 @0 d4 \3 Y6 i( @+ j8 i
- Removing intermediate container 0fa2151dc7b0Successfully built 25453e89b3f01 G( I8 d0 r3 P8 [( q F$ g R
但是当我尝试运行时,它会引发以下错误:- C8 _- }7 f4 Y
- [root@hadoop01 myjavadir]# docker run runhelloworld
3 h9 `" e- e2 U& w - exec: "/bin/sh": stat /bin/sh: no such file or directory
$ \+ _) b6 U1 m& E - Error response from daemon: Cannot start container 676717677d3f1bf3b0b000d68b60c32826939b8c6ec1b5f2e9876969c60e22a4: [8] System error: exec: "/bin/sh": stat /bin/sh: no such file or directory* ]: B0 h; L- `! @* k' D1 a
- [root@hadoop01 myjavadir]# exec: "/bin/sh": stat /bin/sh: no such file or directorybash: exec:: command not found
) Z; H2 x j1 M/ G/ `" Y! T 请帮助解决相同问题。2 P \! u: `9 j. L& |
我知道答案 回答被采纳将会获得8 金钱 已有0人回答 |
|
|
|
|
|