无法找到 root 用户:Docker 中的 passwd 文件中没有匹配的条目 [英] Unable to find user root: no matching entries in passwd file in Docker

查看:30
本文介绍了无法找到 root 用户:Docker 中的 passwd 文件中没有匹配的条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个 Atlassian 产品的容器;JIRABitbucketConfluence.当我尝试访问我通常使用的正在运行的容器时:

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.

这是第一个故障点,脚本每周运行一次(由Jenkins调度).

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

当脚本向 Bitbucket 容器执行这两行时,结果是:

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

它在docker cp"命令上失败,但仅针对 Bitbucket 容器.脚本运行后,bitbucket"(在 Dockerfile 中定义)和root"用户都无法访问容器.

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.

我能够将 /etc/passwd 从容器中复制出来,并且它包含了预期的所有用户.尝试通过 uid 访问时,出现以下错误:

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"

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"]

附加信息:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆