azure - azure自托管代理linux不能与 “--once”参数一起运行

标签 azure docker azure-devops azure-pipelines azure-devops-self-hosted-agent

我喜欢每个管道只运行一次自托管的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 n
我在哪里需要在dockerized代理中设置此“--once”命令?

最佳答案

用于代理的run,而不是docker run。来自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).


因此,您需要将其添加到配置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

关于azure - azure自托管代理linux不能与 “--once”参数一起运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63899209/

相关文章:

azure - 连接-AzureAD : parsing_wstrust_response_failed: Parsing WS-Trust response failed

c# - 递归上传到Azure文件/创建子文件夹

azure-devops - 适用于 Azure DevOps 的带有 azure-pipelines.yml 的 SpecFlow 示例

c# - 需要帮助为新的 Azure 队列客户端版本设置 QueueMessageEncoding.Base64

visual-studio - Visual Studio 2019 重新下载 Azure Function CLI 工具

docker - Google Container Engine 上的跨区域负载均衡 + 路由

django - 在 Amazon Elastic Beanstalk 上使用 SQS 的 Celery 在消息等待时经常长时间暂停

docker - Elastic Beanstalk Docker - 如何获取容器日志

docker - 访问容器从Azure VSTS上的Hosted Linux Agent从Docker Compose步骤启动

azure-devops - 在 VSTS/Azure DevOps 中重置分支更新的构建策略