简体   繁体   English

azure 自托管代理 linux 不使用“--once”参数运行

[英]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.

相关问题 用于运行 pytest 的 Azure 自托管代理 - Azure Self hosted agent to run pytest 在 Kubernetes 上运行 Azure 以 podman 作为无特权容器的自托管代理 - Run Azure Self-hosted agent with podman as unpriviliged container on Kubernetes Azure DevOps self hosted windows agent to Azure Linux function app deployment - Azure DevOps self hosted windows agent to Azure Linux function app deployment azure 管道如何从 jenkins 服务器触发构建并将文件从自托管 linux 代理复制到托管代理并在托管代理上构建 - azure pipeline how to trigger build from jenkins server and copy files from with self-hosted linux agent to hosted agent and build on hosted agent 在 azure 构建管道中,一旦推送自托管代理,如何清理 docker 图像(作为管道的一部分创建)? - In the azure build pipeline, how to cleanup the docker images (created as part of the pipeline) from self hosted agent once it is pushed? 如何在 Azure 云中使用自托管代理 - How to use an Self hosted agent in Azure Cloud 如何在自托管 Windows 代理上从 Azure DevOps 管道运行 Azure CLI 任务? - How to run Azure CLI tasks from an Azure DevOps Pipeline on a Self-Hosted Windows Agent? 如何通过 bash 检查 Linux 上自托管 Azure DevOps 代理上正在运行的作业 - How to check running job on self-hosted Azure DevOps Agent on Linux via bash 嗨,我正在尝试在自托管代理上运行我的 azure 管道,但出现错误 - Hi I'm trying to run my azure pipeline on self hosted agent but getting error 如何使用服务帐户凭据在 Linux 上运行 Azure 代理? - How do I run the Azure Agent on Linux with Service Account credentials?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM