How to add user with dockerfile?

Use useradd instead of its interactive adduser to add user.

RUN useradd -ms /bin/bash  vault

Below command will not create user .

USER vault
WORKDIR /usr/local/bin/vault

it will use vault user

please Refer Dockerfile User Documentation

The USER instruction sets the user name or UID to use when running the
image and for any RUN, CMD and ENTRYPOINT instructions that follow it
in the Dockerfile.

NOTE : Ensures that bash is the default shell.

If default shell is /bin/sh you can do like:

RUN ln -sf /bin/bash /bin/sh
RUN useradd -ms /bin/bash  vault

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)