欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > 能源 > 整合记录-持续

整合记录-持续

2025/3/15 1:03:44 来源:https://blog.csdn.net/weixin_40159431/article/details/146242200  浏览:    关键词:整合记录-持续
启动虚拟机:vagrant up
连接虚拟机:vagrant ssh
关闭虚拟机:vagrant halt
连接虚拟机后关闭:shutdown -h now
查看容器日志:docker logs 容器id|容器名字
查看容器(已启动的):docker ps
查看容器(已启动、未启动但不包括已删除的):docker ps -a
重启容器:docket restart 容器id|容器名字
停止容器:docket stop 容器id|容器名字
启动容器:docket start 容器id|容器名字
设置容器跟随虚拟机启动而启动:
docker update 容器名字|容器id --restart=always

一、安装虚拟机:VirtualBox + vagrant

1、下载安装VirtualBox
https://www.virtualbox.org/,注意:要开启cpu虚拟化(查看是否已开启:任务管理器->性能->CPU->右下角显示虚拟化是否已开启)
VirtualBox-7.1.6-167084-Win.exe
2、下载安装vagrant:
Vagrant官方镜像仓库(这里有许多镜像可直接使用如centos/7,后续会用到):https://app.vagrantup.com/boxes/search
Vagrant下载(百度搜vagrant官网也行):https://developer.hashicorp.com/vagrant/install?product_intent=vagrant#windows
vagrant_2.4.3_windows_amd64.msi
验证是否安装成功:cmd窗口输入命令 vagrant 后有命令提示即安装成功
3、初始化一个centos7系统(在指定文件夹下打开cmd窗口):
在非C盘的目录下打开,如D:\software\mirros
运行 Vagrant init centos/7
4、启动虚拟机:
vagrant up
(需要在Vagrantfile文件所在文件夹打开cmd执行此命令,我的在目录D:\software\mirros),系统root密码是vagrant
5、连接虚拟机:
vagrant ssh
6、设置虚拟机的固定ip地址
修改Vagrantfile文件的config.vm.network “private_network”, ip: "192.168.33.10"即可
ip修改规则:
(1)cmd窗口输入ipconfig找到“以太网适配器 以太网 2”有的叫以太网 ****也有的叫VirtualBox Host-Only Network
(2)如该ip为192.168.56.1那么上面的配置就应该配置为192.168.56.*如config.vm.network “private_network”, ip: “192.168.56.10”
(3)重启虚拟机:vagrant reload
重启后查看虚拟机ip(ifconfig/ip addr)之后和主机相互ping下看看是否通

二、Centos 修改yum华为源

1、备份原配置文件:
cd /etc/yum.repos.d
sudo mv CentOS-Base.repo CentOS-Base.repo.backup
2、创建CentOS-Base.repo文件并插入一下内容

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#[base]
name=CentOS-$releasever - Base - repo

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词