Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CentOS running with systemd #15

Open
ronaldtse opened this issue Jun 15, 2018 · 0 comments
Open

CentOS running with systemd #15

ronaldtse opened this issue Jun 15, 2018 · 0 comments

Comments

@ronaldtse
Copy link
Contributor

@drystone as spoken, here's how you enable systemd in a CentOS container.

FROM centos

ENV container docker

# Update yum repos
RUN yum clean expire-cache && yum install -y yum-utils deltarpm && yum upgrade -y

# yum fails on checksums if built on docker host based on overlayfs
# https://github.com/docker/docker/issues/10180
RUN yum install -y yum-plugin-ovl

# elinks and screen for convenience
RUN yum install -y curl sudo tar hostname iproute secure-delete \
    elinks screen \
  && yum clean all

# From https://hub.docker.com/_/centos/
# Dockerfile for systemd base image
# Systemd is now included in both the centos:7 and centos:latest base
# containers, but it is not active by default. In order to use systemd, you
# will need to include text similar to the example Dockerfile below.
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/*;

# We may also want to remove systemd-update-utmp to remove the failures about it
# rm -f /lib/systemd/system/systemd-update-utmp*; \

# FIXME: A RedHat guy's workaround
# https://vpavlin.eu/2015/02/fedora-docker-and-systemd/
# And also from here
RUN systemctl mask systemd-remount-fs.service dev-hugepages.mount \
  sys-fs-fuse-connections.mount systemd-logind.service getty.target \
  console-getty.service
# Unnecessary to mask
# sys-kernel-config.mount sys-kernel-debug.mount systemd-udevd.service

RUN cp /usr/lib/systemd/system/dbus.service /etc/systemd/system/; \
  sed -i 's/OOMScoreAdjust=-900//' /etc/systemd/system/dbus.service

VOLUME ["/sys/fs/cgroup"]

ENTRYPOINT ["/usr/sbin/init"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant