Skip to content

Instantly share code, notes, and snippets.

@jarek-przygodzki
Last active February 5, 2022 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarek-przygodzki/802d9bbbe2f3d9b8fb5efd02d99e9619 to your computer and use it in GitHub Desktop.
Save jarek-przygodzki/802d9bbbe2f3d9b8fb5efd02d99e9619 to your computer and use it in GitHub Desktop.
CentOS8 systemd
FROM centos:8
# https://github.com/systemd/systemd/blob/v239/src/basic/virt.c#L443
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
RUN dnf install -y java-11-openjdk-headless
# RUN dnf install -y java-11-openjdk-devel
CMD ["/usr/sbin/init"]
# Build
docker build --rm -f CentOS8-systemd-java.dockerfile -t jprzygodzki/centos-systemd-java11:8 .
# Run
docker run --rm -it --name c8-systemd -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v "WHERE_THE_RPMS_ARE:/rpms" --tmpfs /run jprzygodzki/centos-systemd-java11:8
# Install
docker exec -it c8-systemd bash
cd /rpms
dnf install LIST-OF_RPMS
# Stop the container
docker stop -t0 c8-systemd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment