(CentOS 7 | Rocky 9) 安装 Docker
其实网上相关的文章已经非常多了,所以这篇文章的作用只是记录和明确一条确定可行的操作路径,为以后的操作节省时间,毕竟像我一样大部分人都不是专业的系统管理员,能够快速解决问题就可以了,并不想做过多的专业研究与探索。
本操作手册是官方手册与网上手册的结合版本,集两家之所长,亲自操作可用。
1. 系统准备
1# 查看系统版本
2$ cat /etc/redhat-release
3> CentOS Linux release 7.6.1810 (Core) // CentOs 7 以上版本
4
5# 查看系统内核版本
6$ uname -r
7> 4.10.4-1.el7.elrepo.x86_64 // 内核版本要>3.10
8
9# 卸载旧版本
10$ yum remove docker \
11 docker-client \
12 docker-client-latest \
13 docker-common \
14 docker-latest \
15 docker-latest-logrotate \
16 docker-logrotate \
17 docker-selinux \
18 docker-engine-selinux \
19 docker-engine
20
21# 安装依赖包
22$ yum install -y yum-utils lvm2 \
23 device-mapper-persistent-data \
bash
2. 添加 Docker 软件源
1# 如果系统已切换到阿里云镜像源地址,可跳过此步。
2# 阿里云镜像自带docker源
3$ yum-config-manager \
4 --add-repo \
5 https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
6
7# 使用官方源
8$ yum-config-manager \
9 --add-repo \
10 https://download.docker.com/linux/centos/docker-ce.repo
11
12$ yum makecache fast
13# CentOS 8 or Rocky 9 使用timer替换fast
14$ yum makecache timer
bash
3. 安装Docker
1# 如果在 Rocky 9 系统上,会提示containerd.io版本过低,或下载失败,需要独立安装containerd.io
2# 可以重试几次
3$ yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
bash
4. 配置 Docker
1// /etc/docker/daemon.json
2{
3 // 添加官方仓库镜像地址,其实也没什么用很慢
4 "registry-mirrors": ["https://registry.docker-cn.com"]
5}
json
- Docker/DockerHub 国内镜像源/加速列表(长期维护) 其实使用中仓库镜像的速度并不理想,还是设置代理更加实用
- 如何优雅的给 Docker 配置网络代理
5. 启动 Docker
6. 测试安装结果
1$ docker run hello-world
2
3Unable to find image 'hello-world:latest' locally
4latest: Pulling from library/hello-world
51b930d010525: Pull complete
6Digest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f
7Status: Downloaded newer image for hello-world:latest
8
9Hello from Docker!
10This message shows that your installation appears to be working correctly.
11
12To generate this message, Docker took the following steps:
13 1. The Docker client contacted the Docker daemon.
14 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
15 (amd64)
16 3. The Docker daemon created a new container from that image which runs the
17 executable that produces the output you are currently reading.
18 4. The Docker daemon streamed that output to the Docker client, which sent it
19 to your terminal.
20
21To try something more ambitious, you can run an Ubuntu container with:
22 $ docker run -it ubuntu bash
23
24Share images, automate workflows, and more with a free Docker ID:
25 https://hub.docker.com/
26
27For more examples and ideas, visit:
28 https://docs.docker.com/get-started/
29
30$ docker compose version
31Docker Compose version vX.X.0
bash
若能正常输出以上信息,则说明安装成功。
相关专栏文章
- Nuitka 参数列表
- ProxmoxVE 配置 DHCP 网络
- Windows防火墙配置
- 在 CentOS 上部署 NetBIOS
- Tmux 命令
- 配置 CentOS 7 的 CT 容器
- Ncftp 使用手册
- Centos7 安装 Postgresql
- 在CentOS中安装 Laravel 框架
- 虚拟主机安装 Laravel 框架
- snap 设置代理
- Rime输入法设置
- Windows系统配置
- 灌篮高手大结局(全国大赛后) 下
- 灌篮高手大结局(全国大赛后) 上
- VScode 在 Docker 容器内开发
- VSCode 配置 Python 开发环境
- ProxmoxVE 配置 BBR
- ProxmoxVE 关闭订阅提示
- Linux 文本文件操作
- Deepin 使用远程桌面
- Hyper-V 下设置 Deepin 分辨率
- VsCode 使用 Remote SSH 连接 Alpine Linux
- Alpine Linux 安装 Bash
- frp安装配置
- Alpine Linux 配置
- screen 命令
- Systemd 系统工具命令指南
- ProxmoxVE 命令行
- Hyper-V 环境下给 CentOS 磁盘扩容
- Hyper-V 下设置 Ubuntu 分辨率
- Windows 10 家庭版安装 Hyper-V
- Hyper-V 网络设置
- Docker Compose 指令
- 使用 SSH 连接 Github
- Alpine Linux 安装 Docker
- Alpine Linux 网络设置
- 虚拟机安装 Alpine Linux 3.16
- 山克 UPS 安装手册
- Git 命令行
- 使用 Snap 安装 Docker
- (CentOS 7 | Rocky 9) 安装 Docker
- 修复 ProxmoxVE RRD 错误
- FFmpeg脚本
- Yum 版本库管理
- Linux系统内核升级
- iptables 配置
- ProxmoxVE 配置 NAT 网络
- MySQL 数据操作
- 使用 nmcli 配置网络
- 使用 sed 命令操作
- Linux 系统初始化配置
- Github使用Hugo生成Blog
- Docker使用命令
- About
- Search