首页 最新 热门 推荐

  • 首页
  • 最新
  • 热门
  • 推荐

Linux 安装 与 Docker 安装 配置镜像

  • 25-02-17 04:01
  • 2837
  • 9247
blog.csdn.net

1.下载 Centos 镜像

Download - The CentOS Project

2.安装VM

 

 https://support.broadcom.com/group/ecx/productdownloads?subfamily=VMware+Workstation+Pro

 下17.5.2版本免费

https://knowledge.broadcom.com/external/article?articleNumber=368667 说明

NZ4RR-FTK5H-H81C1-Q30QH-1V2LA

许可证

 

 

 

 

 

 

 带界面的

 配置网络

 

先看网段 

点击虚拟网络编辑器 

先点击一下NAT模式的那个 看子网 192.168.181  所以我们的网段必须跟这个前三个一样

vm    .2默认是网关 所以最好我们选取的时候往后面排 

配置主机名 点击应用 

点击完成

 安装完成

3.安装Docker

1.先执行删除以前版本的Docker

  1. sudo yum remove docker \
  2. docker-client \
  3. docker-client-latest \
  4. docker-common \
  5. docker-latest \
  6. docker-latest-logrotate \
  7. docker-logrotate \
  8. docker-engine

2.安装yum存储库

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

这时候会出来一个镜像已经无法抵达的错误 

  1. Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
  2. 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"

3.解决错误 

我们的服务器没法访问镜像的网络,所以我们需要配置正确的镜像源;

进入 /etc/yum.repos.d文件目录;

cd /etc/yum.repos.d
1.先备份
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

编辑CentOS-Base.repo 文件(必选)

 全选替换 centos-base.repo

  1. # CentOS-Base.repo
  2. #
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client. You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you, as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12. [base]
  13. name=CentOS-$releasever - Base
  14. baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
  15. gpgcheck=1
  16. gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  17. #released updates
  18. [updates]
  19. name=CentOS-$releasever - Updates
  20. baseurl=https://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
  21. gpgcheck=1
  22. gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  23. #additional packages that may be useful
  24. [extras]
  25. name=CentOS-$releasever - Extras
  26. baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
  27. gpgcheck=1
  28. gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  29. #contrib - packages by Centos Users
  30. [centosplus]
  31. name=CentOS-$releasever - Plus
  32. baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
  33. gpgcheck=1
  34. enabled=0
  35. gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

 第一个就行  我用上面那个就好使

或者

  1. # CentOS-Base.repo
  2. #
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client. You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you, as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12. [base]
  13. name=CentOS-$releasever - Base - mirrors.aliyun.com
  14. failovermethod=priority
  15. baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
  16. http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
  17. http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
  18. gpgcheck=1
  19. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  20. #released updates
  21. [updates]
  22. name=CentOS-$releasever - Updates - mirrors.aliyun.com
  23. failovermethod=priority
  24. baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
  25. http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
  26. http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
  27. gpgcheck=1
  28. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  29. #additional packages that may be useful
  30. [extras]
  31. name=CentOS-$releasever - Extras - mirrors.aliyun.com
  32. failovermethod=priority
  33. baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
  34. http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
  35. http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
  36. gpgcheck=1
  37. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  38. #additional packages that extend functionality of existing packages
  39. [centosplus]
  40. name=CentOS-$releasever - Plus - mirrors.aliyun.com
  41. failovermethod=priority
  42. baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
  43. http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
  44. http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
  45. gpgcheck=1
  46. enabled=0
  47. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  48. #contrib - packages by Centos Users
  49. [contrib]
  50. name=CentOS-$releasever - Contrib - mirrors.aliyun.com
  51. failovermethod=priority
  52. baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
  53. http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
  54. http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
  55. gpgcheck=1
  56. enabled=0
  57. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
2.编辑 CentOS-SCLo-scl-rh.repo 文件:(没有不用管)

替换内容: ***注意哦!!!***这里不是全部替换,只替换【centos-sclo-rh】下面的内容。

  1. [centos-sclo-rh]
  2. name=CentOS-$releasever - SCLo rh
  3. baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/rh/
  4. gpgcheck=1
  5. enabled=1
  6. gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
3.编辑 CentOS-SCLo-scl.repo 文件(如果没有这个文件,不用管)
  1. [centos-sclo-sclo]
  2. name=CentOS-$releasever - SCLo sclo
  3. baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/sclo/
  4. gpgcheck=1
  5. enabled=1
  6. gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
4.清理缓存、重新加载缓存
清理缓存 
yum clean all
加载缓存 
yum makecache

完美解决

此方法引入 感谢博主

【CentOS7】yum 报错:Could not retrieve mirrorlist http://mirrorlist.centos.org_loading mirror speeds from cached hostfile could n-CSDN博客

4.配置镜像源 

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

 5.安装最新版本

sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

如果想安装具体版本

  1. dnf list docker-ce --showduplicates | sort -r
  2. docker-ce.x86_64 3:27.4.0-1.el9 docker-ce-stable
  3. docker-ce.x86_64 3:27.3.1-1.el9 docker-ce-stable
  4. <...>
sudo yum install docker-ce- docker-ce-cli- containerd.io docker-buildx-plugin docker-compose-plugin

6.启动docker

sudo systemctl enable --now docker

7.拉取Hello world 镜像 并运行

sudo docker run hello-world
1.出现报错
  1. Unable to find image 'hello-world:latest' locally
  2. docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": context deadline exceeded.
  3. See 'docker run --help'.
2.配置阿里云镜像

sudo mkdir -p /etc/docker
  1. sudo tee /etc/docker/daemon.json <<-'EOF'
  2. {
  3. "registry-mirrors": ["https://udron5t9.mirror.aliyuncs.com"]
  4. }
  5. EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
3.最后把镜像在做上补充
vim /etc/docker/daemon.json
  1. {
  2. "registry-mirrors": [
  3. "https://docker.registry.cyou",
  4. "https://docker-cf.registry.cyou",
  5. "https://dockercf.jsdelivr.fyi",
  6. "https://docker.jsdelivr.fyi",
  7. "https://dockertest.jsdelivr.fyi",
  8. "https://mirror.aliyuncs.com",
  9. "https://dockerproxy.com",
  10. "https://mirror.baidubce.com",
  11. "https://docker.m.daocloud.io",
  12. "https://docker.nju.edu.cn",
  13. "https://docker.mirrors.sjtug.sjtu.edu.cn",
  14. "https://docker.mirrors.ustc.edu.cn",
  15. "https://mirror.iscas.ac.cn",
  16. "https://docker.rainbond.cc",
  17. "https://udron5t9.mirror.aliyuncs.com"
  18. ]
  19. }
  1. systemctl daemon-reload
  2. systemctl restart docker

再次保存重启

4.运行 Hello world

完美解决 

这样docker就安装完毕了 

注:本文转载自blog.csdn.net的荭色海湾的文章"https://blog.csdn.net/qq_53374893/article/details/144474902"。版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。如有侵权,请联系我们删除。
复制链接
复制链接
相关推荐
发表评论
登录后才能发表评论和回复 注册

/ 登录

评论记录:

未查询到任何数据!
回复评论:

分类栏目

后端 (14832) 前端 (14280) 移动开发 (3760) 编程语言 (3851) Java (3904) Python (3298) 人工智能 (10119) AIGC (2810) 大数据 (3499) 数据库 (3945) 数据结构与算法 (3757) 音视频 (2669) 云原生 (3145) 云平台 (2965) 前沿技术 (2993) 开源 (2160) 小程序 (2860) 运维 (2533) 服务器 (2698) 操作系统 (2325) 硬件开发 (2491) 嵌入式 (2955) 微软技术 (2769) 软件工程 (2056) 测试 (2865) 网络空间安全 (2948) 网络与通信 (2797) 用户体验设计 (2592) 学习和成长 (2593) 搜索 (2744) 开发工具 (7108) 游戏 (2829) HarmonyOS (2935) 区块链 (2782) 数学 (3112) 3C硬件 (2759) 资讯 (2909) Android (4709) iOS (1850) 代码人生 (3043) 阅读 (2841)

热门文章

115
云原生
关于我们 隐私政策 免责声明 联系我们
Copyright © 2020-2025 蚁人论坛 (iYenn.com) All Rights Reserved.
Scroll to Top