【问题标题】:Docker Busybox container add groups and userDocker Busybox 容器添加组和用户
【发布时间】:2016-06-13 15:44:26
【问题描述】:

我的 docker 容器中需要用户。我的构建来自缺少 groupadd 的 busybox 图像,我尝试使用 apt-get 添加它,但这也丢失了。我需要向我的 Dockerfile 添加什么来获取 groupadd?

目前为止

FROM busybox
RUN apt-get install bash
RUN groupadd -r postgres && useradd -r -g postgres postgres
CMD /bin/sh

【问题讨论】:

    标签: linux docker containers busybox


    【解决方案1】:

    您正在尝试在非 Debian 系统上运行基于 Debian 的命令。如果您需要apt-get 和其他类似的工具,您应该使用FROM debian 更改您的基本映像。

    Busybox 确实包含addgroup,语法如下:

    / # addgroup --help
    BusyBox v1.24.2 (2016-03-18 16:38:06 UTC) multi-call binary.
    
    Usage: addgroup [-g GID] [-S] [USER] GROUP
    
    Add a group or add a user to a group
    
        -g GID  Group id
        -S  Create a system group
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-26
      • 1970-01-01
      • 2019-02-13
      • 2020-11-07
      • 1970-01-01
      相关资源
      最近更新 更多