简体   繁体   English

无法找到 root 用户:Docker 中的 passwd 文件中没有匹配的条目

[英]Unable to find user root: no matching entries in passwd file in Docker

I have containers for multiple Atlassian products;我有多个 Atlassian 产品的容器; JIRA , Bitbucket and Confluence . JIRABitbucketConfluence When I'm trying to access the running containers I'm usually using:当我尝试访问正在运行的容器时,我通常使用:

docker exec -it -u root ${DOCKER_CONTAINER} bash

With this command I'm able to access as usual, but after running a script to extract and compress log files, I can't access that one container anymore.使用此命令,我可以像往常一样访问,但是在运行脚本以提取和压缩日志文件后,我无法再访问该容器。

Excerpt from the 'clean up script'摘自“清理脚本”

This is the first point of failure, and the script is running once each week (scheduled by Jenkins).这是第一个故障点,脚本每周运行一次(由 Jenkins 调度)。

docker cp ${CLEAN_UP_SCRIPT} ${DOCKER_CONTAINER}:/tmp/${CLEAN_UP_SCRIPT}
if [ $? -eq 0 ]; then
  docker exec -it -u root ${DOCKER_CONTAINER} bash -c "cd ${LOG_DIR} && /tmp/compressOldLogs.sh ${ARCHIVE_FILE}"
fi

When the script executes these two lines towards the Bitbucket container the result is:当脚本对 Bitbucket 容器执行这两行时,结果是:

unable to find user root: no matching entries in passwd file

It's failing on the 'docker cp'-command, but only towards the Bitbucket container.它在“docker cp”命令上失败,但仅针对 Bitbucket 容器。 After the script has ran, the container is unaccessible with both the 'bitbucket' (defined in Dockerfile) and 'root' users.脚本运行后,“bitbucket”(在 Dockerfile 中定义)和“root”用户都无法访问容器。

I was able to copy /etc/passwd out of the container, and it contains all of the users as expected.我能够将/etc/passwd从容器中复制出来,并且它包含了所有预期的用户。 When trying to access by uid, I get the following error:尝试通过 uid 访问时,出现以下错误:

rpc error: code = 2 desc = oci runtime error: exec failed: process_linux.go:75: starting setns process caused "fork/exec /proc/self/exe: no such file or directory"

Dockerfile for Bitbucket image: Bitbucket 镜像的 Dockerfile:

FROM                        java:openjdk-8-jre

ENV BITBUCKET_HOME          /var/atlassian/application-data/bitbucket
ENV BITBUCKET_INSTALL_DIR   /opt/atlassian/bitbucket
ENV BITBUCKET_VERSION       4.12.0
ENV DOWNLOAD_URL            https://downloads.atlassian.com/software/stash/downloads/atlassian-bitbucket-${BITBUCKET_VERSION}.tar.gz

ARG user=bitbucket
ARG group=bitbucket
ARG uid=1000
ARG gid=1000

RUN mkdir -p $(dirname $BITBUCKET_HOME) \
    && groupadd -g ${gid} ${group} \
    && useradd -d "$BITBUCKET_HOME" -u ${uid} -g ${gid} -m -s /bin/bash ${user}

RUN mkdir -p                                ${BITBUCKET_HOME} \
    && mkdir -p                             ${BITBUCKET_HOME}/shared \
    && chmod -R 700                         ${BITBUCKET_HOME} \
    && chown -R ${user}:${group}            ${BITBUCKET_HOME} \
    && mkdir -p                             ${BITBUCKET_INSTALL_DIR}/conf/Catalina \
    && curl -L --silent                     ${DOWNLOAD_URL} | tar -xz --strip=1 -C "$BITBUCKET_INSTALL_DIR" \
    && chmod -R 700                         ${BITBUCKET_INSTALL_DIR}/ \
    && chown -R ${user}:${group}            ${BITBUCKET_INSTALL_DIR}/

${BITBUCKET_INSTALL_DIR}/bin/setenv.sh

USER        ${user}:${group}

EXPOSE      7990
EXPOSE      7999

WORKDIR     $BITBUCKET_INSTALL_DIR
CMD         ["bin/start-bitbucket.sh", "-fg"]

Additional info:附加信息:

  • Docker version 1.12.0, build 8eab29e Docker 版本 1.12.0,构建 8eab29e
  • docker-compose version 1.8.0, build f3628c7 docker-compose 版本 1.8.0,构建 f3628c7
  • All containers are running at all times, even Bitbucket works as usual after the issue occurres所有容器一直在运行,甚至Bitbucket在问题发生后也照常运行
  • The issue disappears after a restart of the container重启容器后问题消失

You can use this command to access to the container with root user:您可以使用此命令以 root 用户访问容器:

docker exec -u 0 -i -t {container_name_or_hash} /bin/bash docker exec -u 0 -i -t {container_name_or_hash} /bin/bash

try debug with that.尝试调试。 i think the script maybe remove or disable root user.我认为该脚本可能会删除或禁用 root 用户。

This issue is caused by a docker engine bug but which is tracked privately , Docker is asking users to restart the engine!此问题是由docker 引擎 bug引起的,但已私下跟踪,Docker 要求用户重新启动引擎!

It seems that the bug is likely to be older than two years!看来这个bug很可能已经超过两年了!

https://success.docker.com/article/ucp-health-checks-fail-unable-to-find-user-nobody-no-matching-entries-in-passwd-file-observed https://success.docker.com/article/ucp-health-checks-fail-unable-to-find-user-nobody-no-matching-entries-in-passwd-file-observed

https://forums.docker.com/t/unable-to-find-user-root-no-matching-entries-in-passwd-file/26545/7 https://forums.docker.com/t/unable-to-find-user-root-no-matching-entries-in-passwd-file/26545/7

... what can I say, someone is doing his best to get more funding. ...我能说什么,有人正在尽最大努力获得更多资金。

Its a Long standing issue, replicated on my old version 1.10.3 to at least 1.17这是一个长期存在的问题,在我的旧版本 1.10.3 上复制到至少 1.17

As mentioned by @sorin the the docker forum says Running docker stop and then docker start fixes the problem but is hardly a long-term solution ...正如@sorin 所提到的,docker 论坛Running docker stop and then docker start fixes the problem but is hardly a long-term solution docker Running docker stop and then docker start fixes the problem but is hardly a long-term solution ......

The docker exec -u 0 -i -t {container_name_or_hash} /bin/bash solution also in the same forum post mentioned here by @ObranZoltan might work for you, but does not work for many. docker exec -u 0 -i -t {container_name_or_hash} /bin/bash解决方案也在@ObranZoltan 在这里提到的同一论坛帖子中可能对您有用,但对许多人不起作用。 See my output below请参阅下面的输出

$ sudo docker exec -u 0 -it berserk_nobel /bin/bash 
exec: "/bin/bash": stat /bin/bash: input/output error

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法找到 root 用户:passwd 文件中没有匹配的条目 - unable to find user root: no matching entries in passwd file Docker 找不到用户:OpenJdk11 的 passwd 文件中没有匹配的条目 - Docker Unable to find user: no matching entries in passwd file for OpenJdk11 Docker 映像构建错误:无法找到用户管理员:passwd 文件中没有匹配的条目 - Docker image build Error : unable to find user admin: no matching entries in passwd file 无法找到用户sail:passwd 文件中没有匹配的条目 - unable to find user sail: no matching entries in passwd file Docker:docker:来自守护进程的错误响应:linux 规范用户:无法找到用户 myuser:passwd 文件中没有匹配的条目 - Docker: docker: Error response from daemon: linux spec user: unable to find user myuser: no matching entries in passwd file VS 代码远程容器:Shell 服务器终止(代码:126,信号:null)无法找到用户 xxx:passwd 文件中没有匹配的条目 - VS code Remote Container : Shell server terminated (code: 126, signal: null) unable to find user xxx: no matching entries in passwd file Docker无法找到文件 - Docker Unable to find file 无法以非root用户身份运行docker? - unable to run docker as non-root user? 无法建立Docker映像,“必须是root用户” - Unable to build docker image, “must be a root user” Docker 文件非 root 用户理论问题 - Docker File Non Root User Theory Question
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM