bash 找不到 docker alpine /bin/sh script.sh

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47270976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 16:35:56  来源:igfitidea点击:

docker alpine /bin/sh script.sh not found

bashshelldockeralpine

提问by Thiago G. Alves

I'm trying to build a docker image that has the openjdk:8-alpineas base.
The problem is when I try to execute a script.sh, returning me the following message:

我正在尝试构建一个以openjdk:8-alpine为基础的docker镜像。
问题是当我尝试执行script.sh 时,返回以下消息:

/bin/sh: bin/script.sh: not found

The script.shis in the bin/folder correctly, that's why I don't know what's the problem.

script.sh是在斌/文件夹正确的,这就是为什么我不知道有什么问题就。

Anyone have any idea?

任何人有任何想法?

Thank you.

谢谢你。

回答by Charles Duffy

Make sure the shebang on the script points to an interpreter that actually exists. Thus, if the script being invoked uses:

确保脚本上的 shebang 指向实际存在的解释器。因此,如果被调用的脚本使用:

#!/bin/bash

...then /bin/bashneeds to actually be installed. (Alternately, you might consider trying to port the script to work with POSIX sh, and modifying its shebang to /bin/sh).

...然后/bin/bash需要实际安装。(或者,您可能会考虑尝试移植脚本以使用 POSIX sh,并将其 shebang 修改为/bin/sh)。

回答by rlandster

I was getting the same error message, but my problem was line-endings: my shell-script used MS-DOS line-endings which ash did not like. Once I converted the script file to Unix line-endings, everything worked.

我收到了相同的错误消息,但我的问题是行尾:我的 shell 脚本使用了 ash 不喜欢的 MS-DOS 行尾。一旦我将脚本文件转换为 Unix 行尾,一切正常。