Skip to content

Instantly share code, notes, and snippets.

@bmangesh
Last active August 29, 2015 14:26
Show Gist options
  • Save bmangesh/28a3185ae109005681ee to your computer and use it in GitHub Desktop.
Save bmangesh/28a3185ae109005681ee to your computer and use it in GitHub Desktop.
Package documentation
By default, the CentOS containers are built using yum's nodocs option, which helps reduce the size of the image. If you install a package and discover files missing, please comment out the line tsflags=nodocs in /etc/yum.conf and reinstall your package.
Systemd integration
Currently, systemd in CentOS 7 has been removed and replaced with a fakesystemd package for dependency resolution. This is due to systemd requiring the CAP_SYS_ADMIN capability, as well as being able to read the host's cgroups. If you wish to replace the fakesystemd package and use systemd normally, please follow the steps below.
Dockerfile for systemd base image
FROM centos:7
MAINTAINER "you" <your@email.here>
ENV container docker
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
RUN yum -y update; yum clean all; \
(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" ]
CMD ["/usr/sbin/init"]
This Dockerfile swaps out fakesystemd for the real package, but deletes a number of unit files which might cause issues. From here, you are ready to build your base image.
docker build --rm -t local/c7-systemd .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment