Answers for "alpine docker add user and group"

0

docker alpine create user and group

# To create a non root group and user inside your Alpine based Dockerfile

# -g is the GID
addgroup -g 1000 groupname

# -u is the UID
# -D permits to create an user without password
adduser -u 1000 -G groupname -h /home/username -D username
Posted by: Guest on April-17-2020
0

alpine docker add user and group

FROM python:3.8.3-alpine

ARG BASE_PATH
ENV BASE_PATH ${BASE_PATH:-/}

# install backend-utils
RUN apk update && apk upgrade && apk add --no-cache \
    bash postgresql-client curl libmagic cairo-dev pango-dev gdk-pixbuf ttf-freefont
# install OS utils
RUN apk update && apk upgrade && apk add --no-cache \
    vim perl curl wget busybox-extras su-exec sudo

ARG UID
ARG GID

ENV USR=appuser
ENV GRP=appgroup
ENV PS1='`date "+%F %T"` \u@\h  \w \n\n  '
ENV PRODUCT_DIR="/opt/foobar"
ENV GRP=appgroup
ENV EDITOR="vim"

VOLUME $PRODUCT_DIR

# Enable host to container edit of proj code on ubuntu and mac.
RUN test -z $(getent group $GID | cut -d: -f1) || \
      groupmod -g $((GID+1000)) $(getent group $GID | cut -d: -f1)

# create a group and user
RUN set -x ; addgroup -g "$GID" -S "$GRP" && \
	adduser \
	--disabled-password \
	-g "$GID" \
	-D \
	-s "/bin/bash" \
	-h "/home/$USR" \
	-u "$UID" \
	-G "$GRP" "$USR" && exit 0 ; exit 1

RUN echo "$USR ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER $USR
ADD --chown=$USR:$GRP "." "/home/$USR/$PRODUCT_DIR"

WORKDIR $PRODUCT_DIR

CMD exec /bin/bash -c "trap : TERM INT; sleep infinity & wait"
Posted by: Guest on July-09-2021

Code answers related to "alpine docker add user and group"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language