[英]azure self hosted agent linux do not run with “--once” parameter
我喜歡每個管道只運行一次自托管的 Linux 容器,這意味着當管道完成時我喜歡容器停止
我看到有一個參數叫做“--once”
請在底部的這個鏈接:
https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops
但是當我像這樣在運行后一次啟動 docker 時:
docker run --once --rm -it -e AZP_WORK=/home/working_dir -v /home/working_dir:/azp -e AZP_URL=https://dev.azure.com/xxxx -e AZP_TOKEN=nhxxxxxu76mlua -e AZP_AGENT_NAME=ios_dockeragent xxx.xxx.com:2000/azure_self_hosted_agent/agent:latest
我越來越 :
unknown flag: --once
See 'docker run --help'.
也如果我把它放在docker文件中
COPY ./start.sh .
RUN chmod +x start.sh
CMD ["./start.sh --once"]
嘗試運行 docker 時出現錯誤:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \\"./start.sh --once\\": stat ./start.sh --once: no such file or directory": unknow
我需要在 dockerized 代理中在哪里設置這個“--once”命令?
用於代理的run
,而不是docker run
。 從文檔:
對於配置為交互運行的代理,您可以選擇讓代理僅接受一項作業。 要在此配置中運行:
./run.sh --once
這種模式下的代理將只接受一項工作,然后優雅地停止運行(對於在 Azure 容器實例等服務上在Docker 中運行非常有用)。
因此,您需要將其添加到配置 docker 映像的 bash 腳本中:
FROM ubuntu:18.04
# To make it easier for build and release pipelines to run apt-get,
# configure apt to not require confirmation (assume the -y argument by default)
ENV DEBIAN_FRONTEND=noninteractive
RUN echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
jq \
git \
iputils-ping \
libcurl4 \
libicu60 \
libunwind8 \
netcat
WORKDIR /azp
COPY ./start.sh .
RUN chmod +x start.sh --once
據我所知,沒有辦法從外面傳入; 您必須進入容器並編輯start.sh
文件以將--once
參數添加到適當的行。
exec ./externals/node/bin/node ./bin/AgentService.js interactive --once & wait $!
cleanup
旁注:根據您的要求,您也可以借此機會從start.sh
刪除未記錄的網絡服務器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.