FeelingLife FeelingLife
首页
  • Go

    • Go基础知识
  • Python

    • Python进阶
  • 操作系统
  • 计算机网络
  • MySQL
  • 学习笔记
  • 常用到的算法
  • Docker
  • Kubernetes
  • Observability
  • 容器底层
其他技术
  • 友情链接
  • 收藏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

xuqil

一介帆夫
首页
  • Go

    • Go基础知识
  • Python

    • Python进阶
  • 操作系统
  • 计算机网络
  • MySQL
  • 学习笔记
  • 常用到的算法
  • Docker
  • Kubernetes
  • Observability
  • 容器底层
其他技术
  • 友情链接
  • 收藏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 环境搭建

    • Docker 环境搭建
      • 卸载旧的版本
      • 安装
        • 在线安装
        • 设置存储库
        • 安装 Docker Engine
        • 离线安装
      • 升级
      • 卸载
      • 更改国内镜像源
  • 《Docker》
  • 环境搭建
xuqil
2023-03-25
目录

Docker 环境搭建

# Docker 环境搭建

官方文档:https://docs.docker.com/engine/install/(其他操作系统可参考)

# 卸载旧的版本

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
1
2
3
4
5
6
7
8

# 安装

# 在线安装

# 设置存储库

安装yum-utils(提供 yum-config-manager 实用程序)和设置存储库

 sudo yum install -y yum-utils device-mapper-persistent-data lvm2
 sudo yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
1
2
3
4

# 安装 Docker Engine

  1. 安装 Docker Engine, containerd, 和 Docker Compose:

    • 安装最新版本

      sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
      
      1
    • 指定 Docker 版本进行安装

      列举 Docker 版本:

      $ yum list docker-ce --showduplicates | sort -r
      
       docker-ce.x86_64  3:18.09.1-3.el7                     docker-ce-stable
       docker-ce.x86_64  3:18.09.0-3.el7                     docker-ce-stable
       docker-ce.x86_64  18.06.1.ce-3.el7                    docker-ce-stable
       docker-ce.x86_64  18.06.0.ce-3.el7                    docker-ce-stable
      
      1
      2
      3
      4
      5
      6

      例如安装 20.10.8 版本的 Docker

      sudo yum install docker-ce-20.10.9-3.el7 docker-ce-cli-20.10.9-3.el7  -y
      
      1
  2. 启动 Docker

    sudo systemctl start docker
    sudo systemctl enable docker
    
    1
    2

# 离线安装

可以直接参见官方文档:https://docs.docker.com/engine/install/centos/

# 升级

要升级 Docker Engine,请下载更新的软件包文件并重复安装过程 (opens new window),使用 yum-y upgrade 而不是 yum-y install,然后指向新文件。

# 卸载

  1. 卸载 Docker Engine, CLI, containerd, 和 Docker Compose packages

    sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
    
    1
  2. 删除镜像、容器和挂载卷等信息

    sudo rm -rf /var/lib/docker
    sudo rm -rf /var/lib/containerd
    
    1
    2

# 更改国内镜像源

可参考:https://developer.aliyun.com/article/1113403

  1. 镜像源

    网易:http://hub-mirror.c.163.com
    中科大镜像地址:http://mirrors.ustc.edu.cn/
    中科大github地址:https://github.com/ustclug/mirrorrequest
    Azure中国镜像地址:http://mirror.azure.cn/
    Azure中国github地址:https://github.com/Azure/container-service-for-azure-china
    DockerHub镜像仓库: https://hub.docker.com/ 
    阿里云镜像仓库: https://cr.console.aliyun.com 
    google镜像仓库: https://console.cloud.google.com/gcr/images/google-containers/GLOBAL (如果你本地可以翻墙的话是可以连上去的 )
    coreos镜像仓库: https://quay.io/repository/ 
    RedHat镜像仓库: https://access.redhat.com/containers
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
  2. 设置镜像源

    sudo mkdir -p /etc/docker
    sudo tee /etc/docker/daemon.json <<-'EOF'
    {
      "registry-mirrors": ["https://cr.console.aliyun.com"]
    }
    EOF
    sudo systemctl daemon-reload
    sudo systemctl restart docker
    
    1
    2
    3
    4
    5
    6
    7
    8
上次更新: 2024/05/29, 06:25:22
最近更新
01
VXLAN互通实验
05-13
02
VXLAN
05-13
03
VLAN
05-13
更多文章>
Theme by Vdoing | Copyright © 2018-2025 FeelingLife | 粤ICP备2022093535号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式