sudo tar cvpzf backup.tgz --exclude=/proc --exclude=/mnt --exclude=/sys --exclude=/backup.tgz /
编写dockerflie
新建目录Dockerfile,在Dockerfile目录下编辑Dockerfile脚本,如下内容:
FROM scratch COPY rootfs / RUN chmod u+s /usr/bin/sudo RUN chmod u+s /usr/bin/passwd RUN chmod u+s /bin/su RUN chmod u+s /bin/ping RUN chmod u+s /bin/mount RUN chmod u+s /bin/umount USER root WORKDIR /home/root
根据情况修改用户名密码
将备份的系统文件导入为docker镜像
1.在Dockerfile目录下新建目录backup
2.将备份好的tar文件解压到backup目录下:tar xvpfz backup.tgz
3.sudo docker build -t centos/centos:7.0 .