How can I add a user with Dockerfile - the following does not work.
USER vault
WORKDIR /usr/local/bin/vault
My full Dockerfile:
FROM alpine:3.4
RUN apk update && apk add curl unzip
RUN useradd -ms /bin/bash vault
USER vault
WORKDIR /usr/local/bin/vault
ADD /vault.hcl /etc/vault/vault.hcl
RUN curl -SL https://releases.hashicorp.com/vault/0.5.0/vault_0.5.0_linux_amd64.zip > vault.zip
RUN unzip vault.zip -d /usr/local/bin && rm vault.zip
Use
useradd
instead of its interactiveadduser
to add user.Below command will not create user .
it will use
vault
userplease Refer Dockerfile User Documentation
NOTE : Ensures that
bash
is the default shell.If default shell is
/bin/sh
you can do like:To add group and to associate a new user, use code below.
OR
RUN addgroup -g 1001 -S appuser && adduser -u 1001 -S appuser -G appuser