用于运行Java程序的DockerFile8金钱.anslist{background:url(source/plugin
技术问答
323 人阅读
|
0 人回复
|
2023-09-11
|
我是Docker的新手,正在尝试从头开始编写新映像。我正在编写此dockerFile来编译和运行同一目录中可用的简单Java程序。这里是dockerfile。
. t6 |8 z" |" Y- FROM scratch
i2 w# z+ `7 B# `/ D: f6 M2 r - CMD javac HelloWorld.javaCMD java HelloWorld
/ q8 q# w; n+ r- j* l Docker构建成功,如下所示; y1 i+ h2 \9 I% g( k, E, m
- [root@hadoop01 myjavadir]# docker build -t runhelloworld .
/ D7 \4 M) k1 ] - Sending build context to Docker daemon 3.072 kB* ]3 f4 o* ~* [/ Q: b9 ~
- Sending build context to Docker daemon
0 S8 ~1 O/ ^( U8 P9 O6 B - Step 0 : FROM scratch
2 q% v# n2 i7 @/ d$ d( k% m7 T8 Q1 u - --->
# v1 a1 V; C$ j$ Y, c, L: R: W - Step 1 : CMD javac HelloWorld.java5 ]/ W3 \- a- B. I$ H+ d# l
- ---> Running in 7298ad7e902f
7 [8 G+ D* h/ ?+ G4 | - ---> f5278ae25f0c9 R( C1 x6 k3 |- b7 H4 d4 @
- Removing intermediate container 7298ad7e902f
$ p9 n0 ]) c, r( |, s; \, G& ? - Step 2 : CMD java HelloWorld
. ~% R' g4 y Y/ V; X4 L, s7 p" ? - ---> Running in 0fa2151dc7b0! p! R) B m/ D! z) i$ W
- ---> 25453e89b3f0. b7 e3 M$ _# X0 e' S
- Removing intermediate container 0fa2151dc7b0Successfully built 25453e89b3f04 z2 C: a! e# }1 r, j
但是当我尝试运行时,它会引发以下错误:
. [& ?( F' `. O! H* V- [root@hadoop01 myjavadir]# docker run runhelloworld1 c. Z i- g+ Q
- exec: "/bin/sh": stat /bin/sh: no such file or directory
$ c) Z! V. P$ p& K" d - Error response from daemon: Cannot start container 676717677d3f1bf3b0b000d68b60c32826939b8c6ec1b5f2e9876969c60e22a4: [8] System error: exec: "/bin/sh": stat /bin/sh: no such file or directory3 i8 d$ [) R% F( N
- [root@hadoop01 myjavadir]# exec: "/bin/sh": stat /bin/sh: no such file or directorybash: exec:: command not found, T! e+ S8 v* E( Q9 w
请帮助解决相同问题。9 O0 ~. k1 v! H3 t5 x5 `
我知道答案 回答被采纳将会获得8 金钱 已有0人回答 |
|
|
|
|
|