Linux CentOS 部署Docker

1. yum 配置

(1)更新yum

bash 复制代码
yum update -y

如果不升级更新yum 可能在后续docker部署后再更新容器会出现oci runtime error等

(2)安装yum工具类准备

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

(3)配置yum源为阿里云yum源

bash 复制代码
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

2. docker 安装

bash 复制代码
yum install docker-ce

中间会遇到需要输入的按y

(1)启动docker服务

bash 复制代码
systemctl start docker

(2)允许docker开机自启动

bash 复制代码
systemctl enable docker

(3)查看docker运行状态

bash 复制代码
systemctl status docker

3. 设置Docker国内镜像源

由于docker默认从docker hub(https://registry.hub.docker.com/)下载镜像,所以速度非常慢,可以通过设置为国内镜像源(加速器)

(1)通过 vi/vim 进入/etc/docker/daemon.json,如果没有这个文件,需要在 /etc/docker目录下手动进行创建这个目录。

(2)然后写入一下的内容

bash 复制代码
{
    "registry-mirrors": [
        "https://dockerproxy.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://docker.nju.edu.cn"
    ]
}

(3)进行重启docker服务

bash 复制代码
# 重新加载 systemd 的配置
sudo systemctl daemon-reload

# 重启 Docker 服务
sudo systemctl restart docker

4. 问题解决

(1)遇到报错

"Repository extras is listed more than once in the configuration

CentOS Linux 8 - AppStream 0.0 B/s | 0 B 00:00

Errors during downloading metadata for repository 'appstream':

错误:为仓库 'appstream' 下载元数据失败 : Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8\&arch=x86_64\&repo=AppStream\&infra=stock [Could not resolve host: mirrorlist.centos.org]"

**原因 :**CentOS Linux 8已于 2021年12月31日停止更新和维护,由于CentOS 团队从官方镜像中移除CentOS 8的所有包,所以在使用yum源安装或更新会报上述失败错误。

解决办法:

执行yum命令,报错Errors during downloading metadata for repository 'appstream': - Curl error (6): Couldn'-CSDN博客我在云服务器Linux CentOS 上面执行yum命令,出现提示"Errors during downloading metadata for repository 'appstream':错误:为仓库 'appstream' 下载元数据失败 : Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?https://blog.csdn.net/u013302168/article/details/141923953?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22141923953%22%2C%22source%22%3A%22u013302168%22%7D

相关推荐
春日见20 分钟前
如何入门端到端自动驾驶?
linux·人工智能·算法·机器学习·自动驾驶
dys_Codemonkey29 分钟前
如何在树莓派上用 VS Code 优雅直连内部的 Ubuntu 子系统/容器用来访问容器内的文件和代码?
linux·运维·ubuntu·树莓派
炸膛坦客1 小时前
Linux - Ubuntu - PC端:(五)shell 操作(终端命令,2026)→ 3)基础命令,27 个常用命令
linux·ubuntu
张道宁1 小时前
Windows 环境下 Docker 部署 YOLOv8 并集成 Spring Boot 完整指南
windows·yolo·docker
·醉挽清风·1 小时前
学习笔记—Linux—文件IO
linux·服务器·学习
宁波阿成2 小时前
OpenClaw 在 Ubuntu 22.04.5 LTS 上的安装与问题处理记录
java·linux·ubuntu·openclaw·龙虾
上海合宙LuatOS2 小时前
LuatOS核心库API——【 string】字符串操作
运维·服务器·物联网·junit·硬件工程·信息与通信·嵌入式实时数据库
徐子元竟然被占了!!2 小时前
Linux的cat
linux·运维·服务器
带娃的IT创业者2 小时前
WeClaw 离线消息队列实战:异步任务队列如何保证在服务器宕机时不丢失任何一条 AI 回复?
运维·服务器·人工智能·python·websocket·fastapi·实时通信
kc胡聪聪2 小时前
nginx的性能优化与监控
运维·nginx·性能优化