如何在一台新centos系统服务器上安装docker

1.更新系统软件包列表

bash 复制代码
sudo yum update

2.卸载旧版本(防止之前未卸载干净)

bash 复制代码
yum remove docker  docker-common docker-selinux docker-engine

3.安装必要的软件包(3个)

bash 复制代码
yum install -y yum-utils device-mapper-persistent-data lvm2

4.设置yum源

bash 复制代码
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo(中央仓库)
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo(阿里仓库)

5.查看可用版本并安装

bash 复制代码
yum list docker-ce --showduplicates | sort -r
bash 复制代码
yum -y install 版本号
例如:yum -y install docker-ce-18.03.1.ce

6.启动docker并设置开机自启

bash 复制代码
systemctl start docker
bash 复制代码
systemctl enable docker

参考:https://cloud.tencent.com/developer/article/1701451

相关推荐
黑猫学长呀10 分钟前
存储宝典第2篇:盲封TT wafer是什么意思?
linux·嵌入式硬件·项目·芯片·ufs·晶圆·产测
Strugglingler20 分钟前
【Linux 用户态操作 UART】
linux·uart
代码熬夜敲Q27 分钟前
ENSP 网络工程实验
linux·运维·服务器
csdn_life181 小时前
OpenClaw v2026.5.12+ 高级密钥管理:使用SecretRef实现真正的隐蔽存储
linux·openclaw
Terrence Shen1 小时前
Claude Code Harness 源码学习讲义
linux·学习·ubuntu
赵药师1 小时前
dpkg: warning: files list file for package ‘libselinux1:amd64‘ missing;
linux·运维·服务器
STDD1 小时前
Samba 文件共享:Linux 服务器与 Windows/Mac 共享文件夹
linux·服务器·windows
liudanzhengxi2 小时前
CRM系统技术文章
linux·服务器·网络·人工智能·新人首发
南境十里·墨染春水2 小时前
守护进程编程流程
linux·学习
j7~2 小时前
【MYSQL】在Centos7和ubuntu22.04环境下安装
数据库·c++·mysql·ubuntu·centos