制作模板
1.安装配置操作系统
1.编辑网卡
[root@temp network-scripts]# vi ifcfg-ens160
[root@temp network-scripts]# cat ifcfg-ens160
TYPE=Ethernet
BOOTPROTO=dhcp
NAME=ens160
DEVICE=ens160
ONBOOT=yes
2.清除密钥文件
[root@temp ~]# cd /etc/ssh/
[root@temp ssh]# ls
moduli ssh_config.d ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key
ssh_config sshd_config ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub ssh_host_rsa_key.pub
[root@temp ssh]# rm -rf ssh_host_*
[root@temp ssh]# ls
moduli ssh_config ssh_config.d sshd_config
3.清除machine-id
清除,不是删除
[root@temp ssh]# cat /etc/machine-id
5f9da25a629841b8bdba92d307182c0d
[root@temp ssh]# cat /dev/null > /etc/machine-id
[root@temp ssh]# cat /etc/machine-id
4.关机
init 0
5.完整克隆(以后用到的虚拟机,都可以进行完整克隆)
6.手工配置静态ip
[root@temp network-scripts]# cat ifcfg-ens160
TYPE=Ethernet
BOOTPROTO=none
NAME=ens160
DEVICE=ens160
ONBOOT=yes
IPADDR=192.168.100.177
NETMASK=255.255.255.0
GATEWAY=192.168.100.2
DNS1=192.168.100.2
[root@temp network-scripts]# nmcli conn down ens160
[root@temp network-scripts]# nmcli conn up ens160
7.修改主机名
[root@temp network-scripts]# hostnamectl set-hostname docker
[root@temp network-scripts]# exit
logout
二、安装docker
yum install -y vim net-tools bash-completion yum-utils
bash 或者退出重新登录,为了自动补全
[root@docker yum.repos.d]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@docker yum.repos.d]# ls
CentOS-Stream-AppStream.repo CentOS-Stream-Extras.repo CentOS-Stream-PowerTools.repo docker-ce.repo
CentOS-Stream-BaseOS.repo CentOS-Stream-HighAvailability.repo CentOS-Stream-RealTime.repo
CentOS-Stream-Debuginfo.repo CentOS-Stream-Media.repo CentOS-Stream-ResilientStorage.repo
CentOS-Stream-Extras-common.repo CentOS-Stream-NFV.repo CentOS-Stream-Sources.repo
查看docker版本
yum list docker-ce --showduplicates | sort -r
默认安装最新版
yum install -y docker-ce
安装指定版本
yum install -y docker-ce-20.10.22 docker-ce-cli-20.10.22
[root@docker yum.repos.d]# docker -v
Docker version 23.0.1, build a5ee5b1
开启docker服务
[root@docker ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://docs.docker.com
[root@docker ~]#
[root@docker ~]# systemctl start docker.service
[root@docker ~]# systemctl enable docker.service
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
# 3 镜像管理
[root@docker ~]# docker help
[root@docker ~]# vim /etc/docker/daemon.json
[root@docker ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://cc2d8woc.mirror.aliyuncs.com"]
}
[root@docker ~]# systemctl daemon-reload
[root@docker ~]# systemctl restart docker