linux的centos系统安装docker

文章目录

  • [一. 安装Docker](#一. 安装Docker)
    • [1. 安装yum-utils包](#1. 安装yum-utils包)
    • [2. 配置Docker yum源](#2. 配置Docker yum源)
    • [3. 安装 Docker CE](#3. 安装 Docker CE)
    • [4. 启动并设置 Docker 开机自启](#4. 启动并设置 Docker 开机自启)
    • [5. 验证Docker安装](#5. 验证Docker安装)
  • [二. 配置镜像加速器](#二. 配置镜像加速器)

一. 安装Docker

1. 安装yum-utils包

shell 复制代码
sudo yum install -y yum-utils

2. 配置Docker yum源

  • 官网源,在没有外网的服务器基本不同,不推荐
shell 复制代码
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  • 阿里云镜像源,国内强烈推荐
shell 复制代码
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

3. 安装 Docker CE

shell 复制代码
yum install -y docker-ce docker-ce-cli containerd.io

4. 启动并设置 Docker 开机自启

shell 复制代码
sudo systemctl start docker
sudo systemctl enable docker

5. 验证Docker安装

shell 复制代码
docker run hello-world

二. 配置镜像加速器

shell 复制代码
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://kxc88bv4.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
相关推荐
爱凤的小光28 分钟前
Linux清理磁盘技巧---个人笔记
linux·运维
耗同学一米八1 小时前
2026年河北省职业院校技能大赛中职组“网络建设与运维”赛项答案解析 1.系统安装
linux·服务器·centos
知星小度S2 小时前
系统核心解析:深入文件系统底层机制——Ext系列探秘:从磁盘结构到挂载链接的全链路解析
linux
2401_890443022 小时前
Linux 基础IO
linux·c语言
智慧地球(AI·Earth)3 小时前
在Linux上使用Claude Code 并使用本地VS Code SSH远程访问的完整指南
linux·ssh·ai编程
原神启动13 小时前
Docker 场景化作业:生产环境容器操作实训
运维·docker·容器
老王熬夜敲代码4 小时前
解决IP不够用的问题
linux·网络·笔记
码里法4 小时前
centos安装nginx并配置https完整版
nginx·https·centos
zly35004 小时前
linux查看正在运行的nginx的当前工作目录(webroot)
linux·运维·nginx
QT 小鲜肉4 小时前
【Linux命令大全】001.文件管理之file命令(实操篇)
linux·运维·前端·网络·chrome·笔记