当前位置: 首页 > news >正文

CentOS7虚拟机下安装及使用Docker

文章目录

  • 一,准备工作
  • 二、安装Docker
  • 三、启动Docker
  • 四、验证Docker
  • 五、使用Docker
  • 六,卸载Docker

有一个Centos7的虚拟机,想要安装个docker测试一些docker用法和熟悉命令

一,准备工作

1,使用uname -r命令检查系统内核版本,只有大于3.10才建议安装Docker
在这里插入图片描述
2,使用yum update命令更新系统
在这里插入图片描述
如果该命令执行报错,类似cannot find a valid baseurl for repo:base/7/x86_64
那就需要更改仓库配置文件了,位置路径如下所示

/etc/yum.repos.d/CentOS-Base.repo

文件完整内容如下,采用了阿里云镜像

# CentOS-Base.repo  
#  
# The mirror system uses the connecting IP address of the client and the  
# update status of each mirror to pick mirrors that are updated to and  
# geographically close to the client.  You should use this for CentOS updates  
# unless you are manually picking other mirrors.  
#  
# If the mirrorlist= does not work for you, as a fall back you can try the  
# remarked out baseurl= line instead.  
#  
#  [base]  
name=CentOS-$releasever - Base - mirrors.aliyun.com  
failovermethod=priority  
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/  http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/  http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/  
gpgcheck=1  
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7  #released updates  
[updates]  
name=CentOS-$releasever - Updates - mirrors.aliyun.com  
failovermethod=priority  
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/  http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/  http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/  
gpgcheck=1  
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7  #additional packages that may be useful  
[extras]  
name=CentOS-$releasever - Extras - mirrors.aliyun.com  
failovermethod=priority  
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/  http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/  http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/  
gpgcheck=1  
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7  #additional packages that extend functionality of existing packages  
[centosplus]  
name=CentOS-$releasever - Plus - mirrors.aliyun.com  
failovermethod=priority  
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/  http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/  http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/  
gpgcheck=1  
enabled=0  
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7  #contrib - packages by Centos Users  
[contrib]  
name=CentOS-$releasever - Contrib - mirrors.aliyun.com  
failovermethod=priority  
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/  http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/  http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/  
gpgcheck=1  
enabled=0  
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

PS:在CentOS环境的Vi编辑器一般模式下,按下yy(yank yank的缩写,意为复制),按下nyy(n为你想要复制的行数),按下p键,复制的文本将被粘贴到光标所在行的下一行。按v进入可视模式,按i进入编辑模式

二、安装Docker

1,安装必要软件包,三个Docker运行所需的依赖包

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

在这里插入图片描述
2,设置Docker镜像源,设置成阿里的镜像源是为了加快安装和后续镜像的下载速度

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

在这里插入图片描述
3,安装最新版本的Docker CE,这一步可能要耗费一点时间

sudo yum install -y docker-ce docker-ce-cli containerd.io

在这里插入图片描述
在这里插入图片描述

三、启动Docker

sudo systemctl start docker 启动服务
sudo systemctl status docker 检查 Docker 服务的状态

在这里插入图片描述

sudo systemctl enable docker 开机自启

四、验证Docker

docker -v
docker --version

在这里插入图片描述
运行hello-world

sudo docker run hello-world

在这里插入图片描述
访问不了docker hub,所以无法运行hello-world,只能运行自己打包的镜像,就是把打包的jar包用docker生成镜像后在运行
在这里插入图片描述

五、使用Docker

具体使用参考以前一篇博文 Docker使用心得与技巧

六,卸载Docker

sudo yum remove docker docker-common docker-selinux docker-engine

在这里插入图片描述

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • qt5.15.2在线安装选项不见了?怎么办?
  • 【Pythonj进阶】Python中的日志记录与监控:跟踪和分析应用程序行为
  • union 的正确食用方法
  • 文件包含漏洞PHP伪协议利用方法
  • Mac 安装 jdk 8详细教程
  • 有限体积法:基于一维稳态扩散问题及其程序实现
  • 计算机网络 第2章 物理层
  • 农产品自主供销系统小程序的设计
  • 94.游戏的启动与多开-互斥量对开检测
  • 同三维S61-20SDI 20倍 HDMI SDI USB3.0 网口 3高清摄像机
  • Azure AI Search 中的二进制量化:优化存储和加快搜索速度
  • 【MySQL】索引使用规则——(覆盖索引,单列索引,联合索引,前缀索引,SQL提示,数据分布影响,查询失效情况)
  • python07-单元测试框架unittest1-1
  • JS都有哪些操作数组的方法
  • JS简介 JS特点
  • JS 中的深拷贝与浅拷贝
  • 78. Subsets
  • AzureCon上微软宣布了哪些容器相关的重磅消息
  • Bytom交易说明(账户管理模式)
  • C语言笔记(第一章:C语言编程)
  • Git 使用集
  • GitUp, 你不可错过的秀外慧中的git工具
  • java取消线程实例
  • PyCharm搭建GO开发环境(GO语言学习第1课)
  • Python中eval与exec的使用及区别
  • rc-form之最单纯情况
  • 多线程 start 和 run 方法到底有什么区别?
  • 检测对象或数组
  • 精益 React 学习指南 (Lean React)- 1.5 React 与 DOM
  • 快速体验 Sentinel 集群限流功能,只需简单几步
  • 数组大概知多少
  • 体验javascript之美-第五课 匿名函数自执行和闭包是一回事儿吗?
  • nb
  • 看到一个关于网页设计的文章分享过来!大家看看!
  • postgresql行列转换函数
  • ​secrets --- 生成管理密码的安全随机数​
  • ​学习笔记——动态路由——IS-IS中间系统到中间系统(报文/TLV)​
  • (10)STL算法之搜索(二) 二分查找
  • (pojstep1.1.2)2654(直叙式模拟)
  • (阿里巴巴 dubbo,有数据库,可执行 )dubbo zookeeper spring demo
  • (层次遍历)104. 二叉树的最大深度
  • (附源码)springboot青少年公共卫生教育平台 毕业设计 643214
  • (附源码)springboot助农电商系统 毕业设计 081919
  • (五)大数据实战——使用模板虚拟机实现hadoop集群虚拟机克隆及网络相关配置
  • (学习日记)2024.03.25:UCOSIII第二十二节:系统启动流程详解
  • (转)es进行聚合操作时提示Fielddata is disabled on text fields by default
  • (转)IIS6 ASP 0251超过响应缓冲区限制错误的解决方法
  • (转)编辑寄语:因为爱心,所以美丽
  • (转载)Google Chrome调试JS
  • .NET Core实战项目之CMS 第一章 入门篇-开篇及总体规划
  • .NET 使用 JustAssembly 比较两个不同版本程序集的 API 变化
  • .net(C#)中String.Format如何使用
  • .NetCore部署微服务(二)
  • .NET成年了,然后呢?
  • .NET国产化改造探索(三)、银河麒麟安装.NET 8环境