[英]When i try to run docker it says /bin/sh: [java,-jar,/bin/sh/hellotm-0.0.1-snapshort.jar]: not found
This is the error I get:这是我得到的错误:
docker run -dit openjdk:8-jdk-alpine
docker images
docker container ls
docker container exec flamboyant_knuth ls /tmp
docker container cp target/HelloTm-0.0.1-SNAPSHOT.jar flamboyant_knuth:/tmp
docker container exec flamboyant_knuth ls /tmp
docker container commit flamboyant_knuth syedwn14/hellotm-0.0.1-snapshort:manual1
docker images
docker run syedwn14/hellotm-0.0.1-snapshort:manual1
docker container commit --change="CMD ["java","-jar","/tmp/hellotm-0.0.1-snapshort.jar"]" flamboyant_knuth syedwn14/hellotm-0.0.1-snapshort:manual2
docker run -p 8080:8080 syedwn14/hellotm-0.0.1-snapshort:manual2
Error:
/bin/sh: [java,-jar,/bin/sh/hellotm-0.0.1-snapshort.jar]: not found
Any help will be great.任何帮助都会很棒。
I faced the same issue, was working on Windows.我遇到了同样的问题,正在研究 Windows。
Actual Problem实际问题
Running the following command docker container commit --change="CMD ["java","-jar","/tmp/hellotm-0.0.1-snapshort.jar"]" flamboyant_knuth syedwn14/hellotm-0.0.1-snapshort:manual2
from cmd or powershell adds Windows line endings (\r\n called CRLF) .运行以下命令
docker container commit --change="CMD ["java","-jar","/tmp/hellotm-0.0.1-snapshort.jar"]" flamboyant_knuth syedwn14/hellotm-0.0.1-snapshort:manual2
来自docker container commit --change="CMD ["java","-jar","/tmp/hellotm-0.0.1-snapshort.jar"]" flamboyant_knuth syedwn14/hellotm-0.0.1-snapshort:manual2
或powershell的手册2 添加了Windows 行尾(\r\n 称为 CRLF) 。
On running the following command, the docker container is started.运行以下命令时,将启动 docker 容器。
docker run -p 8080:8080 syedwn14/hellotm-0.0.1-snapshort:manual2
Once the docker container has started it tries to execute the bash command.一旦 docker 容器启动,它就会尝试执行 bash 命令。
["java","-jar","/tmp/hellotm-0.0.1-snapshort.jar"]
But instead throws an error而是抛出一个错误
/bin/sh: [java,-jar,/bin/sh/hellotm-0.0.1-snapshort.jar]: not found.
For the bash command to be executed properly we need to convert the line endings of this command to Linux EOL (\n called "LF") .为了正确执行 bash 命令,我们需要将此命令的行尾转换为Linux EOL (\n called "LF") 。
Easiest Solution that I use:我使用的最简单的解决方案:
docker container commit --change="CMD ["java","-jar","/tmp/hellotm-0.0.1-snapshort.jar"]" flamboyant_knuth syedwn14/hellotm-0.0.1-snapshort:manual2
. docker container commit --change="CMD ["java","-jar","/tmp/hellotm-0.0.1-snapshort.jar"]" flamboyant_knuth syedwn14/hellotm-0.0.1-snapshort:manual2
。 This will ensure that the line endings are Linux EOL . Note: On running docker container exec flamboyant_knuth ls /tmp
from Git Bash you will face the following error message.注意:在从 Git Bash 运行
docker container exec flamboyant_knuth ls /tmp
时,您将面临以下错误消息。
$ docker container exec elated_fermat ls /tmp
ls: C:/Users/<user_name>/AppData/Local/Temp: No such file or directory
Instead run the command on either cmd or powershell .而是在cmd或powershell上运行命令。
Here's the Link to download Git Bash for Windows这是下载 Git Bash的链接,用于 Windows
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.