【问题标题】:What is the default user for Linux Alpine?Linux Alpine 的默认用户是什么?
【发布时间】:2019-07-26 03:42:06
【问题描述】:

我在此处运行 Dockerfile,并希望在跟随 this 设置 memcached 之后“改回”为普通 Linux Alpine 用户。

FROM python:3.6-alpine

# Bunch of Linux / Django / Node stuff

COPY boot.sh /boot.sh
RUN apk --no-cache add memcached && chmod +x /boot.sh

USER memcached
CMD ["/boot.sh"]

# Change back to default user here
USER root

ADD docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

这个的语法是什么?我暂时使用了USER root。它是否正确?我没有在USER memcached 之前的任何地方引用USER

【问题讨论】:

    标签: dockerfile alpine


    【解决方案1】:

    我相信USER root 是正确的。默认的 docker 用户通常是 root

    我能找到的最接近的参考是 Docker 文档中的 USER 命令:
    https://docs.docker.com/engine/reference/builder/#user

    警告:当用户没有主组时,图像(或接下来的说明)将与根组一起运行。

    但是,使用简单的 Dockerfile 很容易自己找到:

    FROM python:3.6-alpine
    RUN whoami
    

    将输出(如果docker 以 root 或 Docker previliged 用户身份启动):

    Step 2/2 : RUN whoami #
     ---> Running in 3a8d159404cd
    root
    

    【讨论】:

      猜你喜欢
      • 2020-04-11
      • 2012-11-29
      • 1970-01-01
      • 2021-07-23
      • 1970-01-01
      • 2016-03-26
      • 1970-01-01
      • 2016-12-19
      • 2016-02-08
      相关资源
      最近更新 更多