gpt4 book ai didi

Docker 错误 : 'useradd: cannot lock/etc/passwd'

转载 作者:行者123 更新时间:2023-12-04 18:00:51 33 4
gpt4 key购买 nike

我在 Azure DevOps 中创建了一个管道来运行 Docker cirrus/flutter 镜像。 Azure 尝试初始化容器时发生错误(在 useradd 命令中)。以下是带有错误的执行日志的最后一部分:

##[command]/usr/bin/docker exec  5ae52fcbeefecc0df48056df5f9d673429fe5173e7a8e3d984d889ce5223c34c sh -c "command -v bash"
/bin/bash
##[command]whoami
vsts
##[command]id -u vsts
1001
Try create an user with UID '1001' inside the container.
##[command]/usr/bin/docker exec 5ae52fcbeefecc0df48056df5f9d673429fe5173e7a8e3d984d889ce5223c34c bash -c "grep 1001 /etc/passwd | cut -f1 -d:"
##[command]/usr/bin/docker exec 5ae52fcbeefecc0df48056df5f9d673429fe5173e7a8e3d984d889ce5223c34c id -u bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
id: extra operand 'warning:'
Try 'id --help' for more information.
##[command]/usr/bin/docker exec 5ae52fcbeefecc0df48056df5f9d673429fe5173e7a8e3d984d889ce5223c34c useradd -m -u 1001 vsts_azpcontainer
useradd: Permission denied.
useradd: cannot lock /etc/passwd; try again later.
##[error]Docker exec fail with exit code 1
##[section]Finishing: Initialize containers

这是我的 azure-pipelines.yml
jobs:
- job: Build
pool:
vmImage: 'ubuntu-16.04'
container: cirrusci/flutter:latest
steps:
- bash: flutter doctor

我该如何解决这个问题?
我感谢大家。

最佳答案

移动 containerresource部分并传递 docker 选项 --user 0:0options .

例如:

resources:
containers:
- container: flutter
image: cirrusci/flutter:latest
options: --user 0:0

jobs:
- job: Build
pool:
vmImage: 'ubuntu-16.04'
container: flutter
steps:
- bash: flutter doctor

关于Docker 错误 : 'useradd: cannot lock/etc/passwd' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54479666/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com