https://hub.docker.com/_/centos/


docker pull centos:6

docker pull centos:6.6


yum:

注释掉 /etc/yum.conf 中tsflags=modocs,重装包


systemd for centos 7系

#systemd 包含在centos:7和centos:latest中,默认没有激活

Dockerfile for sytemd base p_w_picpath

FROM centos:7 MAINTAINER "you" <your@email.here> 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" ] CMD ["/usr/sbin/init"]


docker build --rm -t local/c7-systemd .


systemd enabled app container

FROM local/c7-systemd RUN yum -y install httpd; yum clean all; systemctl enable httpd.service EXPOSE 80 CMD ["/usr/sbin/init"]


$ docker build --rm -t local/c7-systemd-httpd


run a systemd enabled container

In order to run a container with systemd, you will need to mount the cgroups volumes from the host. Below is an example command that will run the systemd enabled httpd container created earlier.

$ docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 local/c7-systemd-httpd