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

WSL 下的 CentOS 装 Docker

WSL 下的 CentOS 装 Docker

  • 卸载旧版本
  • 安装前的准备工作
    • 1. 安装 yum-utils
    • 2. 添加阿里云的 yum 镜像仓库
    • 3. 快速生成 Yum 缓存
  • 安装Docker
  • 启动docker
  • 运行 hello-world
  • 卸载 Docker 引擎
  • 参考资料

卸载旧版本

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

结果显示一堆 No Match for argument: xxx 表示我们没装过 xxx 是干净的。

安装前的准备工作

1. 安装 yum-utils

yum-utils 是一组用于管理 Yum 软件仓库和软件包的实用工具集合。
比如下面要用的 yum-config-manager 就是 yum-utils 中的一个工具。主要用于管理 Yum 软件源配置,可以添加、删除、启用或禁用软件源等操作。

sudo yum install -y yum-utilsLoaded plugins: fastestmirror                                                                                           
Loading mirror speeds from cached hostfile                                                                              
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version                                           
Nothing to do # 没啥要做的,表示我之前已经装过了

2. 添加阿里云的 yum 镜像仓库

注意:整个安装过程,只有这一步与官方不同。因为我们要用阿里的镜像仓库,其他步骤都一样。.

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

添加前、后执行 yum repolist 对比查看,多了一个仓库
在这里插入图片描述

在这里插入图片描述

3. 快速生成 Yum 缓存

当需要频繁安装、更新软件包时,或在新安装的系统中,运行 yum makecache fast 可生成缓存以提高后续操作效率。

yum makecache fast
  • makecache:表示创建或更新缓存
  • fast:表示快速模式。(可能会跳过一些可能比较耗时的检查,比如检查 GPG 签名等。)

安装Docker

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

以下是对安装的这些软件包的说明:

软件包名称说明
docker-ceDocker 引擎社区版,是 Docker 容器运行的核心组件,负责创建、运行和管理容器。
docker-ce-cliDocker 命令行工具,用于与 Docker 引擎进行交互,通过命令行执行各种 Docker 操作,如创建容器、启动容器、管理镜像等。
containerd.io一个行业标准的容器运行时,它为 Docker 和其他容器化技术提供底层的容器运行支持,负责管理容器的生命周期、存储、网络等。
docker-buildx-pluginDocker Buildx 插件,用于构建多架构的 Docker 镜像,允许在不同的平台和架构上构建和推送容器镜像。
docker-compose-pluginDocker Compose 插件,用于定义和运行多容器的 Docker 应用程序,通过一个 YAML 文件来配置多个容器的服务、网络和存储等,简化了多容器应用的部署和管理。

启动docker

sudo systemctl start docker

运行 hello-world

通过运行 hello-world 镜像来验证 Docker Engine 安装是否成功。

sudo docker run hello-world

如果不加 sudo 无法执行 docker 相关命令,说明当前用户可能不在 docker 组里。我们手动加一下:
docker 组是安装 docker 时自动添加的,用来管理操作 docker 的权限)

# 查看,没有 docker 组
groups
# 将用户名 jerry 添加进 docker 组 
sudo usermod -aG docker jerry
# 刷新 docker 组
newgrp docker
# 查看,有 docker 说明就ok了
groups

显示这一堆表示成功

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:53cc4d415d839c98be39331c948609b659ed725170ad2ca8eb36951288f81b75
Status: Downloaded newer image for hello-world:latestHello 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/

卸载 Docker 引擎

  1. 卸载 Docker 引擎、命令行界面(CLI)、containerd 和 Docker Compose 软件包。
sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
  1. 残留需要自己手动清理
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

参考资料

笑虾:Wni11 下 WSL 安装 CentOS
Install Docker Engine on CentOS

相关文章:

  • Ubuntu 22.04 make menuconfig 失败原因
  • SAP学习笔记 - 开发03 - CDSView开发环境搭建,Eclipse中连接SAP,CDSView创建
  • 认知杂谈54
  • AAudio的延迟优化
  • SpringMVC基于注解使用:国际化
  • 点云数据常见的坐标系有哪些,如何进行转换?
  • 红旗EQM换电连接器哪家生产
  • Vue3 父子传参 简单易懂
  • 视频处理基础之gradio框架实现
  • Transformer从零详细解读
  • 5G前传-介绍
  • IBM Storwize V7000存储控制器故障节点报错574
  • Redis典型应用 - 分布式锁
  • SVN下载安装使用方法
  • 【大数据】深入浅出Hadoop,干货满满
  • [分享]iOS开发 - 实现UITableView Plain SectionView和table不停留一起滑动
  • [译] 怎样写一个基础的编译器
  • 「前端」从UglifyJSPlugin强制开启css压缩探究webpack插件运行机制
  • 【跃迁之路】【735天】程序员高效学习方法论探索系列(实验阶段492-2019.2.25)...
  • Android 初级面试者拾遗(前台界面篇)之 Activity 和 Fragment
  • Angular js 常用指令ng-if、ng-class、ng-option、ng-value、ng-click是如何使用的?
  • EOS是什么
  • extjs4学习之配置
  • Javascript 原型链
  • Mac转Windows的拯救指南
  • Mithril.js 入门介绍
  • MySQL常见的两种存储引擎:MyISAM与InnoDB的爱恨情仇
  • OpenStack安装流程(juno版)- 添加网络服务(neutron)- controller节点
  • Vue2.0 实现互斥
  • 从地狱到天堂,Node 回调向 async/await 转变
  • 从伪并行的 Python 多线程说起
  • 大快搜索数据爬虫技术实例安装教学篇
  • 多线程 start 和 run 方法到底有什么区别?
  • 开源地图数据可视化库——mapnik
  • 前端路由实现-history
  • 如何使用Mybatis第三方插件--PageHelper实现分页操作
  • 如何优雅地使用 Sublime Text
  • 入职第二天:使用koa搭建node server是种怎样的体验
  • 使用 5W1H 写出高可读的 Git Commit Message
  • 数组大概知多少
  • 问题之ssh中Host key verification failed的解决
  • 物联网链路协议
  • 原创:新手布局福音!微信小程序使用flex的一些基础样式属性(一)
  • scrapy中间件源码分析及常用中间件大全
  • ​​​【收录 Hello 算法】9.4 小结
  • #Datawhale AI夏令营第4期#AIGC文生图方向复盘
  • #laravel 通过手动安装依赖PHPExcel#
  • (16)Reactor的测试——响应式Spring的道法术器
  • (32位汇编 五)mov/add/sub/and/or/xor/not
  • (poj1.3.2)1791(构造法模拟)
  • (webRTC、RecordRTC):navigator.mediaDevices undefined
  • (附源码)计算机毕业设计ssm基于B_S的汽车售后服务管理系统
  • (四)七种元启发算法(DBO、LO、SWO、COA、LSO、KOA、GRO)求解无人机路径规划MATLAB
  • (五)MySQL的备份及恢复
  • (原+转)Ubuntu16.04软件中心闪退及wifi消失