Docker 安装与卸载
2024-09-02 05:52:16
Docker卸载与安装
卸载旧的版本
卸载
yum -y remove docker-ce docker-cli-io containerd.io
rm -rf var /var/lib/docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
安装 yum-utils 包
安装
yum-utils
包(提供yum-config-manager
实用程序)并设置稳定的存储库。
sudo yum install -y yum-utils
[root@localhost ~]# sudo yum install -y yum-utils
已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
无须任何处理
设置存储库
鉴于国内网络问题,强烈建议使用国内源
sudo yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
官方源
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
[root@localhost ~]# sudo yum-config-manager \
> --add-repo \
> https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, product-id, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://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
安装 docker
安装
docker
sudo yum install docker-ce docker-ce-cli containerd.io
[root@localhost ~]# yum install docker-ce docker-ce-cli containerd.io
已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 containerd.io.x86_64.0.1.4.9-3.1.el7 将被 安装
---> 软件包 docker-ce.x86_64.3.20.10.7-3.el7 将被 安装
--> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-20.10.7-3.el7.x86_64 需要
---> 软件包 docker-ce-cli.x86_64.1.20.10.7-3.el7 将被 安装
--> 正在处理依赖关系 docker-scan-plugin(x86-64),它被软件包 1:docker-ce-cli-20.10.7-3.el7.x86_64 需要
--> 正在检查事务
---> 软件包 docker-ce-rootless-extras.x86_64.0.20.10.7-3.el7 将被 安装
---> 软件包 docker-scan-plugin.x86_64.0.0.8.0-3.el7 将被 安装
--> 解决依赖关系完成
……省略
启动
docker
sudo systemctl start docker
查看
docker
状态
sudo systemctl status docker
测试 docker
通过运行hello world映像验证
Docker
引擎是否已正确安装。如下说明安装成功
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:df5f5184104426b65967e016ff2ac0bfcd44ad7899ca3bbcf8e44e4461491a9e
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:
https://docs.docker.com/get-started/
开机自启
systemctl enable docker
镜像加速器
- 阿里云加速器(点击管理控制台 -> 登录账号(淘宝账号) -> 右侧镜像工具 -> 镜像加速器 -> 复制加速器地址)
- 网易云加速器
https://hub-mirror.c.163.com
- 百度云加速器
https://mirror.baidubce.com
- 中国科技大学 https://docker.mirrors.ustc.edu.cn
- ustc https://docker.mirrors.ustc.edu.cn
- Docker中国区官方镜像 https://registry.docker-cn.com
请首先执行以下命令,查看是否在
docker.service
文件中配置过镜像地址。
systemctl cat docker | grep '\-\-registry\-mirror'
如果该命令有输出,那么请执行
$ systemctl cat docker
查看ExecStart=
出现的位置,修改对应的文件内容去掉--registry-mirror
参数及其值,并按接下来的步骤进行配置。
如果以上命令没有任何输出,那么就可以在
/etc/docker/daemon.json
中写入如下内容(如果文件不存在请新建该文件):
{
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
}
注意,一定要保证该文件符合 json 规范,否则 Docker 将不能启动。
重启
docker
服务
sudo systemctl daemon-reload
sudo systemctl restart docker
参考文档
https://yeasy.gitbook.io/docker_practice/install/centos
最新文章
- Java 二叉树遍历右视图-LeetCode199
- 自己写的java excel导出工具类
- 微信小程序开发:http请求
- 重置mysql管理员密码
- 使用awrextr.sql导出awr原始数据
- log4j(一)——为什么要用log4j?
- js滚动加载小插件
- Video clip 视频剪辑:入门级
- 最近面试被问到一个问题,AtomicInteger如何保证线程安全?
- GUI学习之五——QPushbutton类学习笔记
- 一个项目中mysql数据库经常死锁的问题解决记录
- css的再深入7(更新中···)
- width多少,超过了用....表示
- Java核心技术之类与对象
- nodejs(一)process模块
- 【Quartz】Quartz将Job保存在数据库中所需表的说明
- flac3d自定义变量输出云图
- 【坚持】Selenium+Python学习之从读懂代码开始 DAY6
- springcloud(十):服务网关zuul初级篇
- 如何让input number类型的标签不产生上下加减的按钮
热门文章
- 「模拟8.19 A嚎叫..(set) B主仆..(DFS) C征程..(DP+堆优化)」
- 【题解】PIZZA 贪心
- HAOI2008 木棍分割 数据结构优化dp+二分答案
- 安装nodejs版本模块报错notsup Unsupported platform for n
- 整合Spring Cloud Stream Binder与RabbitMQ进行消息发送与接收
- release模式下打断点调试 配置选项
- 47、django工程(template)
- Gym 101308D	Database 枚举
- LAMP——搭建基于Apache、wordpress、nfs、mysql、DNS的系统
- Linux基础 -02