Centos7五步安装Docker并解决docker官方镜像无法访问问题

2023-11-10

根据官方文档:https://docs.docker.com/install/linux/docker-ce/centos/搭建docker
1.卸载docker旧版本:

sudo yum remove docker 
                  docker-client 
                  docker-client-latest 
                  docker-common 
                  docker-latest 
                  docker-latest-logrotate 
                  docker-logrotate 
                  docker-selinux 
                  docker-engine-selinux 
                  docker-engine

2.安装相关工具类:

sudo yum install -y yum-utils 
  device-mapper-persistent-data 
  lvm2

3.配置docker仓库:

sudo yum-config-manager 
--add-repo 
https://download.docker.com/linux/centos/docker-ce.repo
会报以下错误:
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
Could not fetch/save url https://download.docker.com/linux/centos/docker-ce.repo to file /etc/yum.repos.d/docker-ce.repo
: [Errno 14] curl#35 - "TCP connection reset by peer

这是由于国内访问不到docker官方镜像的缘故
可以通过aliyun的源来完成:

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
出现以下内容则表示docker仓库配置成功:
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

4.安装docker

sudo yum install docker-ce
出现以下异常:
Loaded plugins: fastestmirror
base
https://download-stage.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer"
Trying other mirror.


 One of the configured repositories failed (Docker CE Stable - x86_64),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=docker-ce-stable ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable docker-ce-stable
        or
            subscription-manager repos --disable=docker-ce-stable

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=docker-ce-stable.skip_if_unavailable=true

failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.
https://download-stage.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer"

分析原因为:阿里的镜像库文件也指向docker官方库,所以需要修改库文件

sudo vim /etc/yum.repos.d/docker-ce.repo
通过命令把https://download-stage.docker.com替换为http://mirrors.aliyun.com/docker-ce
命令如下:
:%s#https://download-stage.docker.com#http://mirrors.aliyun.com/docker-ce#g

在执行安装docker的部分妈可安装成功。

sudo yum install docker-ce
内容如下:
Installed:
  docker-ce.x86_64 0:18.03.0.ce-1.el7.centos

Dependency Installed:
  audit-libs-python.x86_64 0:2.7.6-3.el7 checkpolicy.x86_64 0:2.5-4.el7   container-selinux.noarch 2:2.42-1.gitad8f0f7.el7 libcgroup.x86_64 0
  libtool-ltdl.x86_64 0:2.4.2-22.el7_3   pigz.x86_64 0:2.3.3-1.el7.centos policycoreutils-python.x86_64 0:2.5-17.1.el7     python-IPy.noarch

Complete!

5.验证docker安装成功:

启动docker:
sudo systemctl start docker
验证docker:
sudo docker run hello-world
则会出现以下异常:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pulling fs layer
docker: error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/registry-v2/docker/registry/v2/blobs/sha256/e3/e38bc07ac18e
See 'docker run --help'.

此错误也是网络问题:国内无法访问dockerhub
配置阿里云的docker镜像库:在阿里云开通容器镜像服务拿到加速地址在执行以下命令:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://{自已的编码}.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

再次验证docker:

sudo docker run hello-world
出现以下内容则表示安装成功:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Centos7五步安装Docker并解决docker官方镜像无法访问问题 的相关文章

随机推荐

  • 软件开发工具的作用

    软件开发不是工程更多的像是一门艺术 不但靠逻辑更需要靠直觉 软件开发中辅助设计的工具只是一个工具 不要为了工具而去用工具 发挥工具的好处 吸收使用多个工具 不生搬硬套 认识到每个工具都有其局限性 因为每个工具只是表述软件设计或者开发中的一个
  • 对于Excel界址点坐标批量转SHP方法——模型构建器

    关于Excel界址点批量转SHP 对界址点进行处理 将所有地块界址点全部放在一起 字段名 地块编号 唯一 拐点编号 X Y 必备 先将整个表加载到arcgis中然后导出 界址点 SHP 按照字段 编号 进行分类 组 模型构建器对 界址点 s
  • 阿里arthas web-console arthas-tunnel-server 支持wss

    arthas tunnel server 没有找到 wss web console js 线上需要https访问 无法在https中去访问 ws 需要支持wss 特殊修改处理下 arthas web console 源码下载 说明https
  • frp内网穿透搭建

    为什么需要内网穿透功能 从公网中访问自己的私有设备向来都是一件难事 自己的台式机 NAS等等设备 它们可能处于路由器后 或者运营商因为IP地址短缺不给你分配公网IP地址 果我们想直接访问这些设备 远程桌面 远程文件 SSH等等 一般来说要通
  • 如何在Jupyter Notebook中自由切换conda虚拟环境pythtorch_gpu

    一般情况 jupyter note在启动时 是与conda的默认虚拟环境 base root 连接 不能和新建虚拟环境pytorch gpu相连接 这需要安装一些插件来建立连接 需要安装的插件及过程 1 首先在conda中激活虚拟环境pyt
  • WDA学习笔记(一)环境准备

    前言 WDA目前在ABAP市场上有一定的需求 例如万科恒大碧桂园这些地产大佬们都用了一些BOPF的东西 多一个技能就多一些 机会 现在来系统了解一下WDA吧 WDA Web Dynpro For Aabap 和WDJ Web Dynpro
  • css多个class时的选择器用法

    http stackoverflow com questions 1041344 how can i select an element with multiple classes answertab active tab top 例如 a
  • dw超链接标签_Dreamweaver如何建立超链接?DW建立超链接方法介绍

    超级链接一般具有三个特点 蓝色 下划线 和手形标记 那么Dreamweaver如何建立超链接 下面小编就为大家介绍DW建立超链接方法 来看看吧 软件名称 Adobe Dreamweaver CS3 官方中文安装版软件大小 76 2MB更新时
  • 控制 matplotlib 子图大小

    效果图 代码 import numpy as np import matplotlib pyplot as plt 调整 matplotlib 子图的大小 x1 np linspace 0 0 5 0 x2 np linspace 0 0
  • Flink分布式执行包括调度、通信机制、检查点

    Flink的分布式执行包括两个重要的进程 master和worker 执行Flink程序时 多个进程参与执行 即作业管理器 Job Manager 任务管理器 Task Manager 和作业客户端 Job Client Flink程序需要
  • 考研DS备考

    23考研算法复习 一 图论相关算法 1 拓扑排序 2 最小生成树 2 1 Prim算法朴素实现 2 2 最小生成树Kruskal实现 3 最短路 3 1朴素版Dijkstra 3 2Bellman ford 3 3Floyd 二 排序相关算
  • Python 快速获取文件夹中的所有文件名,并保存到txt文件中

    下面的代码可以读取文件夹中的所有文件名 并记录到txt文件中 可以应用到如深度学习制作数据集等场景中 usr bin env python encoding utf 8 import os img path images img list
  • Windows防火墙阻止了远程调试

    问题 当调试数据库里的存储过程时提示 Windows防火墙当前阻止了远程调试 当接着打开SQL Server的时候提示 远程过程调用失败 解决办法 1 当遇到远程过程调试失败
  • windows下查看GPU使用率

    进入C Program Files NVIDIA Corporation NVSMI 在此处打开cmd 输入nvidia smi 第一行Driver Version 表示驱动是385 54 第二行中 第一行表示GPU序号 名字 Persis
  • python作业题

    1 输入三个坐标表示三角形的三个顶点 计算三角形的面积 import math x1 y1 x2 y2 x3 y3 eval input x1 y1 x2 y2 x3 y3 如果不在一条直线上就构成了三角形 if x1 x2 y1 y2 x
  • GMM-HMM在语音识别中的应用

    1 语音识别系统的基本结构 2 涉及算法 3 GMM高斯混合模型 3 1高斯混合模型的基本概念 高斯混合模型是指具有如下形式的概率分布模型 p y k 1k k y k p y arrowvert theta sum k 1 k alpha
  • docker redis单例安装

    环境 windows docker desktop 版本 19 03 12 1 下载redis的docker镜像 docker pull redis 6 0 8 2 设置docker共享目录 docker中的共享目录 即能将宿主的文件同步到
  • Pandas

    文章目录 1 什么是Pandas 2 Pandas的数据结构 2 1 Series 2 1 1 Series的创建 2 1 2 Series的属性 2 2 DataFrame 2 2 1 DataFrame的创建 2 2 2 DataFra
  • 在linux上odoo搭建

    一 配置Postgresql数据库 1 安装Postgresql root runner home sg os apt get install postgresql 2 配置postgresql 拷贝 var lib postgresql
  • Centos7五步安装Docker并解决docker官方镜像无法访问问题

    根据官方文档 https docs docker com install linux docker ce centos 搭建docker 1 卸载docker旧版本 sudo yum remove docker docker client