云与虚拟化_实验1
实验1
下载使用虚拟机
然后快照回溯到init
网络:
推荐改为NAT模式:
开机就好啦
实验1 安装和使用Docker
登录名:
root
openstack
步骤1、2 关闭防火墙和SELinux
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
# 关闭SELinux
setenforce 0
# i 进入输入模式,ESC+:wq 退出编辑模式
vi /etc/selinux/config
把SELINUX 改为:SELINUX=disabled
步骤3 修改网卡配置信息
可能更简单方法
nmtui
改信息:
改成自动然后删掉IP
【俩ESC】
reboot
登录后输入
ip addr
这个就是IP地址啦
修改DNS
vi /etc/sysconfig/network-scripts/ifcfg-ens33
加入DNS1=114.114.114.114
重启下网络
测试与外网的连通性。
[root@node-a ~]# ping -c 4 www.sina.com.cn
PING ww1.sinaimg.cn.w.alikunlun.com (27.221.120.196) 56(84) bytes of data.
64 bytes from 27.221.120.196 (27.221.120.196): icmp_seq=1 ttl=128 time=1.07 ms
64 bytes from 27.221.120.196 (27.221.120.196): icmp_seq=2 ttl=128 time=0.348 ms
64 bytes from 27.221.120.196 (27.221.120.196): icmp_seq=3 ttl=128 time=0.553 ms
64 bytes from 27.221.120.196 (27.221.120.196): icmp_seq=4 ttl=128 time=0.449 ms
--- ww1.sinaimg.cn.w.alikunlun.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 4015ms
rtt min/avg/max/mdev = 0.348/0.606/1.074/0.279 ms
[root@node-a ~]#
SSH连接
在cmd里
ssh root@192.168.59.128 (这里是你的ip)
输入yes
4.更新yum仓库信息
yum -y update
5. 配置时间同步
yum –y install ntpdate
ntpdate ntp.aliyun.com
6 7 8. 安装docker
yum remove docker docker-common docker-selinux docker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2
# 中科大镜像源
yum-config-manager --add-repo http://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
选择并且安装
yum list docker-ce --showduplicates | sort -r
安装
yum install –y docker-ce.x86_64 3:24.0.6-1.el7
11.开机自启、开机启动
systemctl start docker
systemctl enable docker
12. 查看docker进程
ps -ef | grep docker
docker version
[root@node-a ~]# ps -ef | grep docker
root 2024 1 0 15:29 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root 2171 1452 0 15:30 pts/0 00:00:00 grep --color=auto docker
[root@node-a ~]# docker version
Client: Docker Engine - Community
Version: 24.0.6
API version: 1.43
Go version: go1.20.7
Git commit: ed223bc
Built: Mon Sep 4 12:35:25 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.6
API version: 1.43 (minimum version 1.12)
Go version: go1.20.7
Git commit: 1a79695
Built: Mon Sep 4 12:34:28 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.24
GitCommit: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
runc:
Version: 1.1.9
GitCommit: v1.1.9-0-gccaecfc
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[root@node-a ~]#
12.镜像加速器
vi /etc/docker/daemon.json
i 输入
ESC -> :wq 保存
{
"registry-mirrors": ["https://x3n9jrcg.mirror.aliyuncs.com"]
}
13. 重启docker
[root@node-a ~]# systemctl daemon-reload
[root@node-a ~]#
[root@node-a ~]# systemctl restart docker
[root@node-a ~]#
14. 下载镜像以便于测试
docker run -dit -p 80:80 nginx:latest
打开网页测试:
实验1-2
1. 步骤1:在可联网的主机上制作docker本地安装包。
附录
删除全部容器
docker rm -f $(docker ps -aq)
-q 是ID