修改Docker文档目录层级,更新Docker脚本,更新Docker文档
All checks were successful
continuous-integration/drone Build is passing
All checks were successful
continuous-integration/drone Build is passing
This commit is contained in:
126
Docker/Docs/安装文档/Centos安装Docker.md
Normal file
126
Docker/Docs/安装文档/Centos安装Docker.md
Normal file
@@ -0,0 +1,126 @@
|
||||
> 本文作者:丁辉
|
||||
|
||||
# Centos安装Docker
|
||||
|
||||
> 整体来说各系统安装方式都相差不大,那么咱们这里只举例 Centos 安装 Docker 形式
|
||||
>
|
||||
> [官网安装文档](https://docs.docker.com/engine/install/)
|
||||
|
||||
## 开始部署
|
||||
|
||||
1. 卸载就办 Docker
|
||||
|
||||
```bash
|
||||
sudo yum remove docker \
|
||||
docker-client \
|
||||
docker-client-latest \
|
||||
docker-common \
|
||||
docker-latest \
|
||||
docker-latest-logrotate \
|
||||
docker-logrotate \
|
||||
docker-engine
|
||||
```
|
||||
|
||||
2. 安装必要依赖
|
||||
|
||||
```bash
|
||||
yum install -y yum-utils device-mapper-persistent-data lvm2
|
||||
```
|
||||
|
||||
**参数解释**
|
||||
|
||||
| 依赖包 | 作用 | 为什么需要 |
|
||||
| :-------------------------------: | :-----------------------: | :-----------------------------------: |
|
||||
| **yum-utils** | 添加和管理 yum 仓库 | 用于添加 Docker 官方仓库 |
|
||||
| **device-mapper-persistent-data** | devicemapper 存储驱动依赖 | 保证 Docker 底层存储驱动正常运行 |
|
||||
| **lvm2** | 提供逻辑卷管理工具 | devicemapper 依赖,提供底层块存储支持 |
|
||||
|
||||
3. 设置存储库
|
||||
|
||||
- 官方源
|
||||
|
||||
```bash
|
||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
```
|
||||
|
||||
- 国内源
|
||||
|
||||
```bash
|
||||
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
|
||||
```
|
||||
|
||||
- 清华 TUNA Docker 源
|
||||
|
||||
```bash
|
||||
cat > /etc/yum.repos.d/docker-ce.repo << 'EOF'
|
||||
[docker-ce-stable]
|
||||
name=Docker CE Stable - $basearch
|
||||
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/$basearch/stable
|
||||
enabled=1
|
||||
gpgcheck=1
|
||||
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
|
||||
|
||||
[docker-ce-stable-debuginfo]
|
||||
name=Docker CE Stable - Debuginfo $basearch
|
||||
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/debug-$basearch/stable
|
||||
enabled=0
|
||||
gpgcheck=1
|
||||
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
|
||||
|
||||
[docker-ce-stable-source]
|
||||
name=Docker CE Stable - Sources
|
||||
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/source/stable
|
||||
enabled=0
|
||||
gpgcheck=1
|
||||
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
|
||||
EOF
|
||||
```
|
||||
|
||||
4. 刷新 YUM 缓存
|
||||
|
||||
```bash
|
||||
yum clean all
|
||||
yum makecache
|
||||
```
|
||||
|
||||
5. 安装最新版
|
||||
|
||||
```bash
|
||||
yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
```
|
||||
|
||||
> 安装特定版本
|
||||
>
|
||||
> - 查看版本库
|
||||
>
|
||||
> ```bash
|
||||
> yum list docker-ce --showduplicates | sort -r
|
||||
> ```
|
||||
>
|
||||
> - 安装
|
||||
>
|
||||
> ```bash
|
||||
> sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
> ```
|
||||
|
||||
6. 启动
|
||||
|
||||
```bash
|
||||
systemctl enable docker
|
||||
systemctl start docker
|
||||
```
|
||||
|
||||
## 卸载 Docker
|
||||
|
||||
1. 卸载软件包
|
||||
|
||||
```bash
|
||||
yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
|
||||
```
|
||||
|
||||
2. 清理文件
|
||||
|
||||
```bash
|
||||
rm -rf /var/lib/docker
|
||||
rm -rf /var/lib/containerd
|
||||
```
|
||||
Reference in New Issue
Block a user