如何在 Docker 上为 Windows 运行 在 alpine 中 运行 一个简单的 #!/bin/sh 脚本
How to run a simple #!/bin/sh script in alpine on Docker for Windows
我正在尝试将脚本添加到 alpine linux docker 文件,但无法 运行 脚本。它总是导致
/bin/sh: /tmp/test.sh: not found
The command '/bin/sh -c /tmp/test.sh' returned a non-zero code: 127
文件设置了可执行标志。
Docker 文件:
FROM alpine
ADD test.sh /tmp/test.sh
RUN /tmp/test.sh
test.sh
#!/bin/sh
echo "Hello World"
输出
docker build --no-cache .
Sending build context to Docker daemon 3.072kB
Step 1/3 : FROM alpine
---> cdf98d1859c1
Step 2/3 : ADD test.sh /tmp/test.sh
---> c81abfa30514
Step 3/3 : RUN /tmp/test.sh
---> Running in 73b702648827
/bin/sh: /tmp/test.sh: not found
The command '/bin/sh -c /tmp/test.sh' returned a non-zero code: 127
如果您正在处理 Windows,请确保您的文件 (test.sh) 以 unix 格式保存。
我正在尝试将脚本添加到 alpine linux docker 文件,但无法 运行 脚本。它总是导致
/bin/sh: /tmp/test.sh: not found
The command '/bin/sh -c /tmp/test.sh' returned a non-zero code: 127
文件设置了可执行标志。
Docker 文件:
FROM alpine
ADD test.sh /tmp/test.sh
RUN /tmp/test.sh
test.sh
#!/bin/sh
echo "Hello World"
输出
docker build --no-cache .
Sending build context to Docker daemon 3.072kB
Step 1/3 : FROM alpine
---> cdf98d1859c1
Step 2/3 : ADD test.sh /tmp/test.sh
---> c81abfa30514
Step 3/3 : RUN /tmp/test.sh
---> Running in 73b702648827
/bin/sh: /tmp/test.sh: not found
The command '/bin/sh -c /tmp/test.sh' returned a non-zero code: 127
如果您正在处理 Windows,请确保您的文件 (test.sh) 以 unix 格式保存。