-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
34 lines (28 loc) · 939 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# https://www.thegeekdiary.com/su-command-not-found/
ARG OS_NAME=ubuntu
FROM debian:latest AS debian
USER root
ARG SUDO_G=sudo
RUN apt-get update && \
apt-get -y install util-linux sudo curl
FROM ubuntu:latest AS ubuntu
USER root
ARG SUDO_G=sudo
RUN apt-get update && \
apt-get -y install util-linux sudo curl
FROM fedora:latest AS fedora
USER root
ARG SUDO_G=wheel
RUN dnf -y update && \
dnf -y install util-linux which sudo curl
FROM ${OS_NAME} AS os
ARG myuser=docker
RUN useradd --system -d "/home/${myuser}" -c ${myuser} -ms $(which bash) "${myuser}" && \
echo "${myuser}:${myuser}" | chpasswd && \
usermod -aG ${SUDO_G} ${myuser}
# Allow sudo with no password
RUN echo "${myuser} ALL=(ALL) NOPASSWD:ALL" | tee -a "/etc/sudoers" > /dev/null
USER "${myuser}:${myuser}"
WORKDIR "/home/${myuser}"
# USER directive is not fully running in a user, test by: echo $USER
# use: sudo su - <user>. Ex: sudo su - docker