【问题标题】:Initialize container, failing when executing useradd in azure pipeline初始化容器,在 Azure 管道中执行 useradd 时失败
【发布时间】:2021-06-03 20:47:34
【问题描述】:

在运行我的天蓝色管道时,我在尝试初始化容器时遇到了以下错误。

OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "useradd": executable file not found in $PATH: unknown

失败的管道的sn-p

resources:
  containers:
  - container: linux2
    image: amazonlinux:latest
    options: --user 0:0

stages:
  - stage: build_stage    
    pool:
      vmImage: 'ubuntu-latest'
      demands:
        - msbuild
        - visualstudio
        - vstest
    
    jobs:
      - job: build_job

        container: linux2

        steps:
          - checkout: self
            clean: true

这似乎可能是权限问题,但我真的不确定。

【问题讨论】:

    标签: azure azure-devops yaml azure-pipelines


    【解决方案1】:

    这是因为amazonlinux:latest 没有useradd 命令。

    AzDev 从映像创建容器,然后添加新用户并将此用户添加到 sudoers 文件(即使您的映像中没有 sudo),然后才运行容器。

    所以最简单的方法就是更改图像。您也可以使用amazonlinux:latest 并添加useradd 并在您的管道中使用它。

    【讨论】:

    • 好的,我明白了,非常感谢。我需要 amazonlinux 映像,因为我需要该映像来匹配部署环境的操作系统,但您现在所说的将为我提供前进的道路。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-25
    • 1970-01-01
    • 2022-10-05
    相关资源
    最近更新 更多