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

蹲街弑〆低调 提交于 2019-11-28 03:48:17

问题


I have containers for multiple Atlassian products; JIRA, Bitbucket and Confluence. 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).

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:

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. After the script has ran, the container is unaccessible with both the 'bitbucket' (defined in Dockerfile) and 'root' users.

I was able to copy /etc/passwd out of the container, and it contains all of the users as expected. When trying to access by uid, I get the following error:

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:

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-compose version 1.8.0, build f3628c7
  • All containers are running at all times, even Bitbucket works as usual after the issue occurres
  • The issue disappears after a restart of the container

回答1:


This issue is caused by a docker engine bug but which is tracked privately, Docker is asking users to restart the engine!

It seems that the bug is likely to be older than two years!

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

... what can I say, someone is doing his best to get more funding.




回答2:


You can use this command to access to the container with root user:

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.




回答3:


Its a Long standing issue, duplicated on my old version 1.10.3 to at least 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...

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. See my output below

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


来源:https://stackoverflow.com/questions/41676835/unable-to-find-user-root-no-matching-entries-in-passwd-file-in-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!