CentOS Docker安装
CentOS Docker安装
Docker支持以下的CentOS版本
- CentOS 7(64-bit)
- CentOS 6.5(64-bit)或更高的版本
前提条件
目前,CentOS仅发行版本中的内核支持Docker。
Docker运行在CentOS 7上,要求系统为64位、系统内核版本味3.10以上。
Docker运行在CentOS 6.5或更高版本的CentOS上,要求系统为64位、系统内核版本位2.6.32-431或更高版本。
使用yum安装(CentOS 7)
Docker要求CentOS系统的内核爸爸嫩高于3.10,查看本页面的前提条件来验证你的CentOS版本是否支持Docker。通过uname -r
命令查看当前内核版本。
[root@xxxxx yum.repos.d]# cat /etc/redhat-release
CentOS Linux release 7.2.2004 (Core)
[root@xxxxx ~]# uname -r
4.18.0-193.14.2.el8_2.x86_64
首先需要大家虚拟机联网,安装yum工具
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2 --skip-broken
然后更新本地镜像源:
# 设置docker镜像源
yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo
yum makecache fast
安装docker-ce 社区版,免费
yum install -y docker-ce
使用yum安装(CentOS 8)
阿里云文档对CentOS8进行了说明,对CentOS8不再进行维护,可通过如下步骤进行切换yum源。
1. 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. 下载最新的CentOS-Base.repo到 /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
删除旧版本docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
安装Docker
Docker软件依赖和依赖包已经包含在默认的CentOS-Extras软件源里,安装命令如下:
yum -y install docker
如果报错:
Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorlist
解决方案:https://blog.csdn.net/weixin_43252521/article/details/124409151
启动命令
# 启动
service docker start
# 配置自动启动
systemctl enable docker.service
# 重启
systemctl restart docker
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通