用于运行Java程序的DockerFile8金钱.anslist{background:url(source/plugin
技术问答
398 人阅读
|
0 人回复
|
2023-09-11
|
我是Docker的新手,正在尝试从头开始编写新映像。我正在编写此dockerFile来编译和运行同一目录中可用的简单Java程序。这里是dockerfile。8 c; H, g/ [# P
- FROM scratch1 o. q# U" C; V7 u
- CMD javac HelloWorld.javaCMD java HelloWorld
- J7 o% i3 N) m0 K- z4 T Docker构建成功,如下所示. c9 k- T) H" A8 l) H7 {
- [root@hadoop01 myjavadir]# docker build -t runhelloworld .
* v+ T& k& L: h - Sending build context to Docker daemon 3.072 kB
6 |( v* J, o( h - Sending build context to Docker daemon
8 O4 d u) d4 B - Step 0 : FROM scratch/ J8 p+ ~: T T. y( d4 v9 j$ h" |
- --->$ X# n1 r! o7 z2 c
- Step 1 : CMD javac HelloWorld.java
4 K h& G( S; U& P+ B( c: j+ D - ---> Running in 7298ad7e902f
! B' x1 q: t8 V9 W - ---> f5278ae25f0c
: `, j+ [: j8 C# w0 \ - Removing intermediate container 7298ad7e902f
5 S& S7 u0 m7 ~0 r- S) _; r - Step 2 : CMD java HelloWorld9 f/ E/ W; n# ~1 B
- ---> Running in 0fa2151dc7b0
3 R6 I" x, S6 J( U - ---> 25453e89b3f02 Y3 t# O. i0 v! H: h
- Removing intermediate container 0fa2151dc7b0Successfully built 25453e89b3f0 f- D4 J+ N2 m& c# ~$ |5 y4 M
但是当我尝试运行时,它会引发以下错误:
- n* y, _' B* B5 V3 |! r$ ]8 K7 w- [root@hadoop01 myjavadir]# docker run runhelloworld% E, ^1 S) B5 r0 L6 t5 |
- exec: "/bin/sh": stat /bin/sh: no such file or directory% ^% [ P6 m3 a [9 w! n$ N% U
- Error response from daemon: Cannot start container 676717677d3f1bf3b0b000d68b60c32826939b8c6ec1b5f2e9876969c60e22a4: [8] System error: exec: "/bin/sh": stat /bin/sh: no such file or directory
' B* z% u+ |4 S; ^7 u U2 T E - [root@hadoop01 myjavadir]# exec: "/bin/sh": stat /bin/sh: no such file or directorybash: exec:: command not found
. n4 q$ b. d8 F4 Z: v4 ^5 z* o6 F 请帮助解决相同问题。. b4 n0 [9 c" e# w2 {" G* q! p
我知道答案 回答被采纳将会获得8 金钱 已有0人回答 |
|
|
|
|
|