centos7之docker使用systemd

# vim Dockerfile

------------------------------------------------------------------------------------------------

FROM centos:7.2.1511
MAINTAINER xiao2
RUN yum -y install systemd systemd-libs
RUN 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"]

------------------------------------------------------------------------------------------------


# docker build -t="centos-7.2.1511:base" .


# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos-7.2.1511     base             8dfc576b95e9        11 minutes ago      241.1 MB
centos              7.2.1511            e4d3abfdeab3        6 days ago          194.6 MB


docker run -id --name test --hostname=test --privileged -e "container=docker" -t centos-7.2.1511:base


# docker ps -a
CONTAINER ID IMAGECOMMAND CREATEDSTATUS PORTSNAMES
f0bc613c6b45 centos-7.2.1511:systemd"/usr/sbin/init" 6 minutes agoExited (137) 2 minutes ago test


你可能感兴趣的:(docker)