简体   繁体   English

当我尝试运行 docker 它说 /bin/sh: [java,-jar,/bin/sh/hellotm-0.0.1-snapshort.jar]: not found

[英]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:manual2powershell手册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:我使用的最简单的解决方案:

  1. Install Git Bash (it provides a UNIX style command interface).安装 Git Bash(它提供了 UNIX 风格的命令界面)。
  2. Run the following command from Git Bash docker container commit --change="CMD ["java","-jar","/tmp/hellotm-0.0.1-snapshort.jar"]" flamboyant_knuth syedwn14/hellotm-0.0.1-snapshort:manual2 . Run the following command from Git Bash 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 .这将确保行结尾是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 .而是在cmdpowershell上运行命令。

Here's the Link to download Git Bash for Windows这是下载 Git Bash的链接,用于 Windows

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 cron 运行 jar 会引发错误:&#39;/bin/sh: 1: java: not found&#39; - Running jar with cron throws error: '/bin/sh: 1: java: not found' / bin / sh:1:未找到触摸 - /bin/sh: 1: touch not found 错误 - / bin / sh:找不到java:命令 - Error - /bin/sh: java: command not found docker centos:6.6镜像“ / bin / sh:java:找不到命令”,安装了java - docker centos:6.6 image “/bin/sh: java: command not found” java is installed Java中的sshpass给出错误:/ bin / sh:sshpass:找不到命令 - sshpass in Java gives error: /bin/sh: sshpass: command not found 如何解决/bin/sh: protoc: command not found? - how to solve /bin/sh: protoc: command not found? Dockerfile: /bin/sh: 1: ./mvnw: 找不到错误 - Dockerfile : /bin/sh: 1: ./mvnw: not found error 通过.sh脚本对Java jar进行基准测试 - Benchmarking a java jar by .sh script IntelliJ 说&#39;无法运行程序&#39;/path/to/tomcat/bin/catalina.sh&#39;错误=13 权限被拒绝 - IntelliJ says 'cannot run program '/path/to/tomcat/bin/catalina.sh' error=13 permission denied 我在OS X Mavericks上运行mvn时出现以下错误:无法运行程序“/ bin / sh”:error = 2,没有这样的文件或目录 - I am getting the following error when I run mvn on OS X Mavericks: Cannot run program “/bin/sh”: error=2, No such file or directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM