-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (44 loc) · 1.75 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM ubuntu:rolling
ARG USERNAME=user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ENV container docker
ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update \
&& apt-get install -y ssh nano net-tools bash-completion dnsutils sudo systemd systemd-sysv git python3 python3-pip locales \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& locale-gen en_US.UTF-8
## Systemd setup
## Adapted from https://github.com/j8r/dockerfiles/blob/master/systemd/ubuntu/20.04.Dockerfile
RUN cd /lib/systemd/system/sysinit.target.wants/ \
&& ls | grep -v systemd-tmpfiles-setup | xargs rm -f $1
RUN rm -f /lib/systemd/system/multi-user.target.wants/* \
/etc/systemd/system/*.wants/* \
/lib/systemd/system/local-fs.target.wants/* \
/lib/systemd/system/sockets.target.wants/*udev* \
/lib/systemd/system/sockets.target.wants/*initctl* \
/lib/systemd/system/basic.target.wants/* \
/lib/systemd/system/anaconda.target.wants/* \
/lib/systemd/system/plymouth* \
/lib/systemd/system/systemd-update-utmp*
##
## install docker
RUN wget -O install.sh https://get.docker.com \
&& bash install.sh \
&& rm install.sh
ENV DEBIAN_FRONTEND interactive
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m -s /bin/bash $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
RUN usermod -aG docker $USERNAME
RUN echo "$USERNAME:ruse" | chpasswd
RUN systemctl enable ssh
RUN systemctl enable docker
# enable login by normal users
RUN systemctl set-default multi-user.target
RUN ln -s /lib/systemd/system/systemd-user-sessions.service /lib/systemd//system/multi-user.target.wants/
CMD ["/lib/systemd/systemd"]