Docker Busybox 容器添加组和用户

Ori*_*Eye 4 linux containers busybox docker

我的 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
Run Code Online (Sandbox Code Playgroud)

BMi*_*tch 5

您正在尝试在非 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
Run Code Online (Sandbox Code Playgroud)