CentOS7虚拟机中如何安装并配置docker套件
更新:HHH   时间:2023-1-7


本篇内容介绍了“CentOS7虚拟机中如何安装并配置docker套件”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

1. 打开vmware, 创建虚拟机, 选择光盘, 下一步

 

2. 选择传统bios

 

3.自定设置

 

4.选择存储虚拟机的位置,存储

 

5. 自定义内存为2g, 磁盘为40gb

 

 

 

6. 开机,选择install centos 7

 

7. 选择语言

 

8.选择磁盘

 

 

9. 设置预装软件

 

10. 节约内存, 关闭kdump

 

 

11. 开启网络, 设置主机名

 

 

12. 开始安装

 13.设置root用户密码, 创建具有sudo权限的用户并设置密码 设置管理员用户

 

 

添加具有sudo权限的用户

 

等读条完成

 

重启

同意协议

完成设置

 

登录

开始使用

安装成功

调整时区

 

选择上海

 

安装配置完成, 享受linux吧

 

centos的优势并不在图形化界面上, 如果你喜欢图形化界面的linux, 这里推荐deepin 和 unbuntu, 如果你对界面的美感要求很高, 建议你试一试号称最美linux的elementaryos

每次拿到一个全新的centos镜像的时候,第一件事就是为centos更换国内源, 新增yum源, 吐槽一下, 默认的yum源对常用软件的支持真的不咋地, 比如我想安装一个 python-pip , 对不起, 没有!

但好在centos也留有余地, 你可以自由地新增一些你喜欢的源, 比如epel(extra packages for enterprise linux)

 

企业版 linux 附加软件包(以下简称 epel)是一个 fedora 特别兴趣小组,用以创建、维护以及管理针对企业版 linux 的一个高质量附加软件包集,面向的对象包括但不限于 红帽企业版 linux (rhel)、 centos、scientific linux (sl)、oracle linux (ol) 。 epel 的软件包通常不会与企业版 linux 官方源中的软件包发生冲突,或者互相替换文件。epel 项目与 fedora 基本一致,包含完整的构建系统、升级管理器、镜像管理器等等。

第一步: 更换

1.1备份旧的yum源

sudo mv /etc/yum.repos.d/centos-base.repo /etc/yum.repos.d/centos-base.repo.bak

1.2将以下内容写入 /etc/yum.repos.d/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
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7

#released updates
[updates]
name=centos-$releasever - updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7

#additional packages that may be useful
[extras]
name=centos-$releasever - extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7

#additional packages that extend functionality of existing packages
[centosplus]
name=centos-$releasever - plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7

1.3刷新yum源

yum clean all && yum makecache && yum update

但是yum源的软件还是太少了, 比如我想安装只有 python-pip 都做不到

 

第二步: 安装阿里epel源

yum -y install epel-release
wget -o /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
# 刷新yum源
yum clean all && yum makecache && yum update

 

 

至此, 我们可以愉快的安装python-pip了, yum install python-pip

 

第三步: 安装docker和docker-compose

1. 安装docker

# 通过yum源安装docker
sudo yum -y install docker
# 启动docker
sudo systemctl start docker
# 开机自启
sudo systemctl enable docker

 

2. 安装docker-compose

sudo pip install docker-compose
# 安装成功后查看
sudo docker-compose --version

 

3. docker 中国官方镜像加速

修改/etc/docker/daemon.json, 加入以下配置

{
"registry-mirrors": ["https://registry.docker-cn.com"]
}

重启docker

sudo service docker restart

“CentOS7虚拟机中如何安装并配置docker套件”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注天达云网站,小编将为大家输出更多高质量的实用文章!

返回大数据教程...