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
相关推荐
淼淼爱喝水1 小时前
openEuler 下 Ansible 模块缺失 / 损坏后重装完整教程
linux·openeuler·技术实操
山城码农笑松哥1 小时前
Rocky Linux Centos 9.6 完全离线安装rabbitmq4.2
linux·rabbitmq
江畔何人初6 小时前
iptables 和 IPVS 代理模式 Service 的区别
linux·运维·服务器·网络·云原生·kubernetes·代理模式
xuefeiniao9 小时前
docker.desktop无法启动,导出镜像后
服务器·docker
123过去9 小时前
nfc-list使用教程
linux·网络·测试工具·安全
灰阳阳10 小时前
Dockerfile实践-构建Nginx镜像
运维·nginx·docker·dockerfile
evo-master11 小时前
网络故障排除方法
linux·服务器·网络
xlq2232214 小时前
35.信号
linux
白鸽梦游指南15 小时前
docker镜像优化
linux·运维·docker
A.A呐15 小时前
【Linux第十九章】网络基础
linux·网络