Skip to content

Instantly share code, notes, and snippets.

@roman4ello
Last active October 2, 2023 10:49
Show Gist options
  • Save roman4ello/4ba42a2a8bb160f2ca9ca74cacb2beea to your computer and use it in GitHub Desktop.
Save roman4ello/4ba42a2a8bb160f2ca9ca74cacb2beea to your computer and use it in GitHub Desktop.
Create user in Dockerfile
FROM amazoncorretto:8u382-alpine-jre
ARG USER_ID=YOUR_USER_ID
ARG GROUP_ID=YOUR_GROUP_ID
ARG USER_NAME=YOUR_USER
ARG GROUP_NAME=YOUR_GROUP
RUN set -x && addgroup -g $GROUP_ID $GROUP_NAME && \
adduser --shell /sbin/nologin \
--disabled-password \
--gecos '' \
--no-create-home \
--uid $USER_ID \
--ingroup $GROUP_NAME \
$USER_NAME && set +x
USER $USER_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment