-
Notifications
You must be signed in to change notification settings - Fork 3
/
rhel7-ubi-init-smallest.Containerfile
43 lines (32 loc) · 1.18 KB
/
rhel7-ubi-init-smallest.Containerfile
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
ARG REGISTRY=registry.access.redhat.com
ARG TAG=latest
FROM ${REGISTRY}/ubi7/ubi-init:${TAG}
LABEL org.opencontainers.image.authors="Jan Hutar <[email protected]>"
RUN INSTALL_PKGS="\
less \
openssh-server \
subscription-manager \
" \
&& echo -e "[repo1]\nname=repo1\nbaseurl=https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi/server/7/7Server/x86_64/os/\ngpgcheck=0\nenabled=1" >/etc/yum.repos.d/repo1.repo \
&& yum -y install $INSTALL_PKGS \
&& rpm -V --nosize --nofiledigest --nomtime --nomode $INSTALL_PKGS \
&& yum clean all
COPY src/renamer.service /etc/systemd/system/renamer.service
RUN systemctl enable renamer.service
ARG ROOT_PASSWORD
ARG ROOT_PUBLIC_KEY
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
if [[ -n "${ROOT_PUBLIC_KEY}" ]]; then \
mkdir -m 700 /root/.ssh && \
install -m 600 /dev/null /root/.ssh/authorized_keys && \
echo "${ROOT_PUBLIC_KEY}" >>/root/.ssh/authorized_keys; \
fi && \
if [[ -n "${ROOT_PASSWORD}" ]]; then \
echo "root:${ROOT_PASSWORD}" | chpasswd; \
fi && \
systemctl enable sshd.service && \
exit 0
RUN rpm -qa | wc -l
WORKDIR /root
EXPOSE 22
CMD ["/sbin/init"]