dockerdebianforgerock

How to adduser when using debian as a base image


I am trying to add an system user from my docker file and i am not able to do that.

I am getting this error every time:

adduser: Only one or two names allowed.
The command '/bin/sh -c apt-get update && apt-get -y --no-install-recommends install unzip curl bash vim dnsutils tini     && rm -fr "$CATALINA_HOME"/webapps/ROOT     && mkdir -p /opt/forgerock     && addgroup --gid 11111 forgerock     && adduser /bin/bash --system --home "$FORGEROCK_HOME" --uid 11111 --group root --disabled-password forgerock     && chown -R forgerock:root "$CATALINA_HOME" "$FORGEROCK_HOME"     && chmod -R g+rwx "$CATALINA_HOME"' returned a non-zero code: 1

The part from docker file where i try to do this is the following:

RUN apt-get update && apt-get -y --no-install-recommends install unzip curl bash vim dnsutils iputils-ping tini \
&& rm -fr "$CATALINA_HOME"/webapps/ROOT \
&& mkdir -p /opt/forgerock \
&& addgroup --gid 11111 forgerock \
&& adduser /bin/bash --system --home "$FORGEROCK_HOME" --uid 11111 --group root --disabled-password forgerock \
&& chown -R forgerock:root "$CATALINA_HOME" "$FORGEROCK_HOME" \
&& chmod -R g+rwx "$CATALINA_HOME"

Would really appreciate your help!


Solution

  • Debian uses the command useradd and usergroup for creating users and groups (rather than adduser and addgroup).

    I modified your Dockerfile snippet to relate with Debian commands:

    RUN apt-get update && apt-get -y --no-install-recommends install unzip curl bash vim dnsutils iputils-ping tini \
    && rm -fr "$CATALINA_HOME"/webapps/ROOT \
    && mkdir -p /opt/forgerock \
    && groupadd -f -g 11111 forgerock \
    && useradd -l -u 11111 -g root -d "$FORGEROCK_HOME" -r forgerock \
    && chown -R forgerock:root "$CATALINA_HOME" "$FORGEROCK_HOME" \
    && chmod -R g+rwx "$CATALINA_HOME"