基于上次制作的centos-ssh:1.0镜像,制作centos7镜像,使其支持systemctl方式管理服务。
1.制作systemctl Dockerfile,并保存
命令:
vim Dockerfile
[root@centos79 ~]# cat Dockerfile
FROM centos-ssh:1.0
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 [
本文介绍了如何基于已有的centos-ssh:1.0镜像,通过编写Dockerfile来创建一个新的centos-systemctl:1.0镜像,使容器内能够使用systemctl管理服务。主要步骤包括编写Dockerfile,构建镜像,启动容器,并通过xshell进行验证。
订阅专栏 解锁全文
1万+

被折叠的 条评论
为什么被折叠?



