Skip to content

Instantly share code, notes, and snippets.

@AntoniosHadji
Created March 23, 2023 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AntoniosHadji/dfbacb813584a52f7dc52740f040633f to your computer and use it in GitHub Desktop.
Save AntoniosHadji/dfbacb813584a52f7dc52740f040633f to your computer and use it in GitHub Desktop.
Dockerfile create and use non-root user inside container
ARG UNAME=antonios
ARG UID=1000
ARG GID=1000
RUN groupadd -g $GID -o $UNAME
RUN useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
RUN usermod -aG sudo $UNAME
USER $UNAME
@AntoniosHadji
Copy link
Author

Change UNAME arg, and use this to have container default user be not root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment