-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile
More file actions
99 lines (90 loc) · 3.64 KB
/
Containerfile
File metadata and controls
99 lines (90 loc) · 3.64 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
FROM ubuntu:22.04
LABEL description="Ubuntu 22.04 LTS (Jammy Jellyfish), Integration Test Target (ITT) with systemd"
LABEL maintainer="foundata GmbH (https://foundata.com)"
# Inform systemd it's running in a container and specify the container manager
# type (this may affect the behavior, see src/basic/virt.c).
# Docker users can overwrite this with "--env container=docker".
ENV container=podman
# Ensure Python output goes directly to the terminal without buffering,
# preventing loss of partial output if an application crashes.
ENV PYTHONUNBUFFERED=1
# Set non-interactive mode for apt to prevent prompts during builds
ARG DEBIAN_FRONTEND=noninteractive
# Install required packages and clean-up package manager caches afterwards.
# Packages are included for these purposes:
#
# - Overall compatibility and network functionality:
# build-essential ca-certificates iproute2 libffi-dev libssl-dev locales
# procps systemd
#
# - Easier debugging within the container (good feature-to-size ratio):
# iputils-ping, iputils-tracepath, less, vim-tiny
#
# - Accessing a container via Ansible:
# python3, python3-apt, sudo
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
iproute2 \
libffi-dev \
libssl-dev \
locales \
procps \
systemd \
iputils-ping \
iputils-tracepath \
less \
vim-tiny \
python3 \
python3-apt \
sudo \
&& rm -rf "/var/lib/apt/lists/"* \
&& apt-get clean \
# Clean up unnecessary installed files that aren't needed in this image.
# --no-install-recommends does not prevent installation of docs for all
# packages, and --path-exclude is only available for dpkg, not for apt-get.
&& rm -rf "/usr/share/doc" \
&& rm -rf "/usr/share/man"
# Configure systemd, mask or remove inconvenient systemd units and services.
# Helpful resources to determine problematic units to be removed:
# systemctl list-dependencies
# systemctl list-units --state=waiting
# systemctl list-units --state=failed
# systemctl mask (if not available: cd path && ln -s -f "/dev/null")
# https://www.freedesktop.org/software/systemd/man/latest/bootup.html
RUN systemctl mask \
# Prevent login prompts, agetty on agetty on tty[1-6] etc.
console-getty.service \
getty.target \
systemd-logind.service \
systemd-ask-password-console.service \
systemd-ask-password-plymouth.service \
systemd-ask-password-wall.service \
# Filesystem related
dev-hugepages.mount \
sys-fs-fuse-connections.mount \
systemd-remount-fs.service \
# Miscellaneous
systemd-initctl.service \
systemd-machine-id-commit.service \
systemd-random-seed.service \
systemd-udevd.service \
systemd-udev-trigger.service \
&& systemctl disable \
# Ubuntu specific
apt-daily-upgrade.timer \
apt-daily.timer \
dpkg-db-backup.timer \
e2scrub_all.timer \
motd-news.timer
# Prevent UTF-8 errors or warnings raised by several tools
RUN locale-gen en_US.UTF-8
# Ensure non-interactive sudo commands work in containerized environments where
# TTY allocation is often unavailable or undesired (if needed, it is usually
# allowed on this platform).
RUN sed -i -e 's/\(^Defaults\s*\)\(requiretty\)/\1!\2/' "/etc/sudoers"
# Define volumes for systemd (Podman will do this automatically, but let's add
# this for best-effort Docker compatibility)
VOLUME ["/run", "/run/lock", "/tmp", "/sys/fs/cgroup/systemd", "/var/lib/journal" ]
# Start systemd init
CMD ["/lib/systemd/systemd"]