用于运行Java程序的DockerFile8金钱.anslist{background:url(source/plugin
技术问答
275 人阅读
|
0 人回复
|
2023-09-11
|
我是Docker的新手,正在尝试从头开始编写新映像。我正在编写此dockerFile来编译和运行同一目录中可用的简单Java程序。这里是dockerfile。, [4 `" a9 b) A7 j
- FROM scratch. a7 L( V+ i& K
- CMD javac HelloWorld.javaCMD java HelloWorld, [, W* W8 ~7 U4 a
Docker构建成功,如下所示
h( V) G) n; J- s5 ?7 o3 E2 M9 n: ]- [root@hadoop01 myjavadir]# docker build -t runhelloworld .
. I. l4 u* ]% j$ i - Sending build context to Docker daemon 3.072 kB
! p) r8 G2 `# }+ v - Sending build context to Docker daemon% u# i. y8 V9 W: L
- Step 0 : FROM scratch/ ]% Q: o' T2 J+ w# o; l
- ---> m3 {; l7 I9 S# h3 V E
- Step 1 : CMD javac HelloWorld.java
$ v N) a) ^2 K! A! n8 d - ---> Running in 7298ad7e902f5 j$ E$ @. N) B5 @2 [
- ---> f5278ae25f0c: M: N+ Y% n6 y
- Removing intermediate container 7298ad7e902f& W0 X6 E r# @7 y0 A
- Step 2 : CMD java HelloWorld+ T5 H" |' E5 l) B+ S/ [
- ---> Running in 0fa2151dc7b0! }% J2 i" n9 {0 w+ u
- ---> 25453e89b3f0
2 }: W$ h! f3 j( V2 c! U6 M - Removing intermediate container 0fa2151dc7b0Successfully built 25453e89b3f05 c/ a7 h, ? I
但是当我尝试运行时,它会引发以下错误:0 n8 b7 i! f E5 B" ?$ L
- [root@hadoop01 myjavadir]# docker run runhelloworld
2 P" P( S8 p+ M7 e" |" q0 g0 s - exec: "/bin/sh": stat /bin/sh: no such file or directory
( F) s- _' ?0 e - Error response from daemon: Cannot start container 676717677d3f1bf3b0b000d68b60c32826939b8c6ec1b5f2e9876969c60e22a4: [8] System error: exec: "/bin/sh": stat /bin/sh: no such file or directory1 e2 _9 H+ L( N3 p! L: B6 U
- [root@hadoop01 myjavadir]# exec: "/bin/sh": stat /bin/sh: no such file or directorybash: exec:: command not found3 Y2 q( ]5 ~, ]& X: T" v
请帮助解决相同问题。
* C* h$ o, X3 u* O我知道答案 回答被采纳将会获得8 金钱 已有0人回答 |
|
|
|
|
|