[英]azure self hosted agent linux do not run with “--once” parameter
i like to run the self-hosted Linux container only once per pipeline that means when the pipeline is done i like the container to stop我喜欢每个管道只运行一次自托管的 Linux 容器,这意味着当管道完成时我喜欢容器停止
i saw that there is a parameter called "--once"我看到有一个参数叫做“--once”
please this link in the bottom :请在底部的这个链接:
https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/docker?view=azure-devops
but when i start the docker like this with the once after the run :但是当我像这样在运行后一次启动 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
I'm getting :我越来越 :
unknown flag: --once
See 'docker run --help'.
also if i put it in the docker file as也如果我把它放在docker文件中
COPY ./start.sh .
RUN chmod +x start.sh
CMD ["./start.sh --once"]
Im getting error when trying to run the docker :尝试运行 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
n 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
where do i need to set this "--once" command in dockerized agent?我需要在 dockerized 代理中在哪里设置这个“--once”命令?
Is for the agent's run
, not the docker run
.用于代理的
run
,而不是docker run
。 from the docs :从文档:
For agents configured to run interactively, you can choose to have the agent accept only one job.
对于配置为交互运行的代理,您可以选择让代理仅接受一项作业。 To run in this configuration:
要在此配置中运行:
./run.sh --once
Agents in this mode will accept only one job and then spin down gracefully (useful for running in Docker on a service like Azure Container Instances).
这种模式下的代理将只接受一项工作,然后优雅地停止运行(对于在 Azure 容器实例等服务上在Docker 中运行非常有用)。
So, you need to add it in the bash script you configure the docker image:因此,您需要将其添加到配置 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
As far as I know, there's no way to pass it in from the outside;据我所知,没有办法从外面传入; you have to go into the container and edit the
start.sh
file to add the --once
argument to the appropriate line.您必须进入容器并编辑
start.sh
文件以将--once
参数添加到适当的行。
exec ./externals/node/bin/node ./bin/AgentService.js interactive --once & wait $!
cleanup
Side note: depending on your requirements, you might also take the opportunity to remove the undocumented web-server from start.sh
.旁注:根据您的要求,您也可以借此机会从
start.sh
删除未记录的网络服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.