Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 0979b05

Browse files
committed
Add Dockerfile example of container image running Systemd (securely)
1 parent 8301453 commit 0979b05

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Nestybox's systemd dockerfile.
2+
#
3+
# Description:
4+
#
5+
# Image's goal is to serve as a basic building-block for users looking to
6+
# run various background processes (daemons) in Nestybox's system containers.
7+
# For this purpose we are installing systemd process-manager as part of this
8+
# Dockerfile.
9+
#
10+
#
11+
# Container initialization:
12+
#
13+
# $ docker run --runtime=sysbox-runc \
14+
# -it --rm --name=sys-cont nestybox/ubuntu-bionic-systemd
15+
#
16+
17+
FROM ubuntu:bionic
18+
19+
#
20+
# Systemd installation
21+
#
22+
RUN apt-get update && \
23+
apt-get install -y --no-install-recommends \
24+
systemd \
25+
systemd-sysv \
26+
libsystemd0 \
27+
ca-certificates \
28+
dbus \
29+
iptables \
30+
iproute2 \
31+
kmod \
32+
locales \
33+
sudo \
34+
udev && \
35+
\
36+
# Prevents journald from reading kernel messages from /dev/kmsg
37+
echo "ReadKMsg=no" >> /etc/systemd/journald.conf && \
38+
\
39+
# Housekeeping
40+
apt-get clean -y && \
41+
rm -rf \
42+
/var/cache/debconf/* \
43+
/var/lib/apt/lists/* \
44+
/var/log/* \
45+
/tmp/* \
46+
/var/tmp/* \
47+
/usr/share/doc/* \
48+
/usr/share/man/* \
49+
/usr/share/local/* && \
50+
\
51+
# Create default 'admin/admin' user
52+
useradd --create-home --shell /bin/bash admin && echo "admin:admin" | chpasswd && adduser admin sudo
53+
54+
55+
# Make use of stopsignal (instead of sigterm) to stop systemd containers.
56+
STOPSIGNAL SIGRTMIN+3
57+
58+
# Set systemd as entrypoint.
59+
ENTRYPOINT [ "/sbin/init" ]

0 commit comments

Comments
 (0)