doudang9147 2019-01-25 01:36
浏览 282

/ bin / sh:1:/go/src/test.sh:未找到

I am trying to build this dockerfile, the file is copied successfully but I keep getting the following error:

docker build --no-cache=true -f Dockerfile-Gobase .

Sending build context to Docker daemon 34MB

Step 1/3 : FROM golang:1.11.2 ---> df6ac9d1bf64

Step 2/3 : COPY ./test.sh /go/src/ ---> 38a538f0289d

Step 3/3 : RUN (ls -l /go/src/ && cd /go/src/ && /go/src/test.sh) ---> Running in 089de53d11f0

total 4

-rwxr-xr-x 1 root root 34 Jan 24 03:22 test.sh

/bin/sh: 1: /go/src/test.sh: not found

The command '/bin/sh -c (ls -l /go/src/ && cd /go/src/ && /go/src/test.sh)' returned a non-zero code: 127

These are the file codes

Dockerfile-Gobase

FROM golang:1.11.2
COPY ./test.sh /go/src/
RUN (ls -l /go/src/ && cd /go/src/ && /go/src/test.sh)

test.sh

#!/bin/sh
echo "hello world"
  • 写回答

1条回答 默认 最新

  • dskm94301 2019-01-25 11:06
    关注

    You eliminated the first cause by checking that the script exists in the container with an ls. This also eliminated Linux file permissions.

    Next possible cause is that your interpreter isn't in the container, but showing the script we see that it's #!/bin/sh. And /bin/sh is included with your base image.

    What's left that I can think of are windows line feeds in the file, a missing library somewhere, or perhaps security tools like SE Linux/AppArmor with a strict configuration. In this case, it looks like windows line feeds were there cause. You just need to configure your editor to output with Linux style line feeds. Otherwise Linux is looking for /bin/sh\R to run (where \R is the carriage return), and that command does not exist.

    This is included in my DockerCon 18 talk which includes lots of other tips you may find useful when starting out.

    评论

报告相同问题?

悬赏问题

  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程