一、现有系统 Centos8.5 操作:
系统里最好不安装 Docker,否则会报错
卸载不必要软件包
ndf remove -y iwl* *firmware* --exclude=kernel-firmware
清理yum缓存
ndf clean all
rm -rf /var/cache/dnf
打包文件系统
tar --numeric-owner --exclude=/proc --exclude=/sys --exclude=/mnt --exclude=/var/cache --exclude=/usr/share/{foomatic,backgrounds,perl5,fonts,cups,qt4,groff,kde4,icons,pixmaps,emacs,gnome-background-properties,sounds,gnome,games,desktop-directories} --exclude=/var/log -zcvf /mnt/CentOS8-mysql-nginx-php.tar.gz /
或者 ,加 压缩
tar -zcvf /var/tmp/CentOS8-mysql-nginx-php.tar.gz \
--exclude=/boot/* \
--exclude=/proc/* \
--exclude=/dev/* \
--exclude=/sys/* \
--exclude=/home/* \
--exclude=/var/lib/* \
--exclude=/lib/modules/* \
--exclude=/var/cache/* \
--exclude=/project/* \
--exclude=/tmp/dxb/* \
--exclude=/root/gitlab* /
二、使用
导入前面打包好的镜像
docker load --input mycentos.tar.gz
导入并运行
docker import CentOS8-mysql-nginx-php.tar centos8 docker run -itd --name xx centos8:latest /bin/bash