You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在AKS托管构建代理Pod中流水线Docker镜像启动失败求助

解决AKS托管Pod代理中容器启动时找不到Node.js路径的问题

问题场景

使用AKS托管Pod构建代理运行流水线时,指定python:3.11容器后出现启动失败错误:

Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/__a/externals/node/bin/node": stat /__a/externals/node/bin/node: no such file or directory: unknown

镜像已成功拉取,但容器无法启动。使用Linux或Azure托管Linux代理池时无此问题,且必须使用AKS托管代理池满足任务需求。

流水线配置片段:

jobs:
- job: RunTests
  displayName: Run Tests
  pool:
    name: aks_hosted_agent_pod
  container:
    image: 'python:3.11'
  steps:
    # 流水线其他阶段

问题原因

AKS托管Pod代理的容器运行环境与Azure托管代理存在本质差异:

  • Azure托管代理在主机层面预安装Node.js,容器运行时会共享主机的工具路径(如/__a/externals/node/);
  • AKS托管代理的Pod与业务容器完全隔离,流水线默认尝试引用代理Pod内的Node.js路径,但python:3.11镜像中不存在该路径,导致容器启动失败。

解决方案

方案1:在业务容器内安装Node.js

直接在python:3.11容器中安装Node.js,让流水线使用容器内的Node环境:

jobs:
- job: RunTests
  displayName: Run Tests
  pool:
    name: aks_hosted_agent_pod
  container:
    image: 'python:3.11'
  steps:
    - script: |
        apt-get update
        apt-get install -y nodejs npm
      displayName: 'Install Node.js in container'
      # 后续测试步骤

如果需要更稳定的环境,可自定义包含Python和Node.js的镜像:

FROM python:3.11
RUN apt-get update && apt-get install -y nodejs npm
# 如需特定Node版本,可改用nvm安装:
# RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# RUN . ~/.bashrc && nvm install 20 && nvm alias default 20

构建并推送镜像后,在流水线中使用自定义镜像即可。

方案2:调整流水线变量指定Node.js路径

通过设置环境变量,让流水线指向容器内的Node.js安装路径,避免引用代理Pod的路径:

jobs:
- job: RunTests
  displayName: Run Tests
  pool:
    name: aks_hosted_agent_pod
  container:
    image: 'python:3.11'
  variables:
    # 将工具目录指向容器内Node的安装路径
    AGENT_TOOLSDIRECTORY: '/usr/bin'
  steps:
    - script: |
        apt-get update
        apt-get install -y nodejs npm
      displayName: 'Install Node.js in container'
    # 后续测试步骤

方案3:检查AKS代理Pod的挂载配置

确认AKS托管代理池的配置中,没有强制将代理Pod的Node.js路径挂载到业务容器。如果存在不必要的卷挂载,移除后可避免路径冲突。

内容的提问来源于stack exchange,提问作者Manoj N D

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 07:32:46