这是我的 Dockerfile
FROM ubuntu:22.04
RUN apt update
RUN apt upgrade -y
RUN apt install -y curl git jq libicu70
# Also can be "linux-arm", "linux-arm64".
ENV TARGETARCH="linux-x64"
WORKDIR /azp/
COPY ./azsh-linux-agent/start.sh ./
RUN chmod +x ./start.sh
RUN useradd agent
RUN chown agent ./
USER agent
ENTRYPOINT ./start.sh
我尝试从 pwd 构建图像
/home/jh/azsh-linux-agent
当我尝试构建时出现错误
docker build --tag "azsh-linux-agent:1.0" --file "./azsh-linux-agent.dockerfile" .
像这样
--------------------
10 | WORKDIR /azp/
11 |
12 | >>> COPY ./azsh-linux-agent/start.sh ./
13 | RUN chmod +x ./start.sh
14 |
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref c6a592e2-a63c-497e-addd-2fab546c3594::hy7y7sols7kbk34sms7iylyew: "/azsh-linux-agent/start.sh": not found
为什么没有检测到脚本?
如果你正在构建
/home/jh/azsh-linux-agent
,那么你需要使用...将文件复制
/home/jh/azsh-linux-agent/start.sh
到 Docker 容器中。或者,您可以使用绝对路径,如下所示