• [云原生.docker安装]Centos7安装docker环境


    目录

    一、Docker版本

    二、一键安装docker及docker-compose

    1、新建docker-install.sh

     2、授权并运行

    三、选择具体版本安装步骤详解

    0、切换root

    1、更新新yum源

    2、yum-utils安装 

    3、Loading mirror speeds from cached hostfile 解决方案

     4、查看仓库中所有docker版本,并选择新版本安装

    5、启动docker

    6、docker ps验证

    7、设置开机自动启动

    一、Docker版本


    Docker 有两个版本:社区版(Community Edition,缩写为 CE)、企业版(Enterprise Edition,缩写为 EE)下面的安装都是社区版。

    二、一键安装docker及docker-compose

    1、新建docker-install.sh

    将以下内容直接copy到docker-install.sh

    #!/bin/bash
    # shellcheck disable=SC2046
    BASE_PATH=$(cd `dirname $0`;pwd)
    echo "当前系统版本:";sudo cat /etc/redhat-release;
    echo -e "\033[46;37;5m -------------- 开始安装docker所需环境 -------------- \033[0m";
    # 安装docker环境
    echo " ------------ 开始安装docker服务 ------------ ";
    yum update -y;
    yum install -y yum-utils device-mapper-persistent-data lvm2;
    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo;
    yum install -y docker-ce;
    systemctl start docker;
    systemctl enable docker;
    docker version;
    sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose;
    sudo chmod +x /usr/local/bin/docker-compose;
    docker-compose version;
    echo " ------------ docker服务安装完毕 ------------ ";

     2、授权并运行

    chmod  777 docker-install.sh

    sh docker-install.sh

    三、选择具体版本安装步骤详解

    0、切换root

    sudo -s

    1、更新新yum源

    yum -y update

    1. Loaded plugins: fastestmirror, langpacks, versionlock
    2. Loading mirror speeds from cached hostfile
    3.  * base: mirrors.aliyun.com
    4.  * extras: mirrors.aliyun.com
    5.  * updates: mirrors.aliyun.com
    6. github_git-lfs/x86_64/signature                                                                                                                                                       |  833 B  00:00:00     
    7. github_git-lfs/x86_64/signature                                                                                                                                                       | 1.8 kB  00:00:00 !!! 
    8. github_git-lfs-source/signature                                                                                                                                                       |  833 B  00:00:00     
    9. github_git-lfs-source/signature                                                                                                                                                       | 1.8 kB  00:00:00 !!! 
    10. Resolving Dependencies
    11. --> Running transaction check
    12. ---> Package at.x86_64 0:3.1.13-24.el7 will be updated
    13. ---> Package at.x86_64 0:3.1.13-25.el7_9 will be an update
    14. ---> Package bash.x86_64 0:4.2.46-34.el7 will be updated 
    15. .........................................................................................
    16. Complete!

    2、yum-utils安装 

    yum install -y yum-utils

    1. Loaded plugins: fastestmirror, langpacks, versionlock
    2. Loading mirror speeds from cached hostfile
    3. Nothing to do 

    3、Loading mirror speeds from cached hostfile 解决方案

    确保服务能连接网络才能执行以下wget命令

     wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 

    yum makecache fast 

    yum install -y yum-utils

    1. [root@]# yum install -y yum-utils
    2. Loaded plugins: fastestmirror, langpacks, versionlock
    3. Loading mirror speeds from cached hostfile
    4. * base: mirrors.aliyun.com
    5. * extras: mirrors.aliyun.com
    6. * updates: mirrors.aliyun.com
    7. github_git-lfs/x86_64/signature | 833 B 00:00:00
    8. github_git-lfs/x86_64/signature | 1.8 kB 00:00:00 !!!
    9. github_git-lfs-source/signature | 833 B 00:00:00
    10. github_git-lfs-source/signature | 1.8 kB 00:00:00 !!!
    11. Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
    12. Nothing to do

     4、查看仓库中所有docker版本,并选择新版本安装

    yum list docker-ce --showduplicates | sort -r

    1. * updates: mirrors.aliyun.com
    2. Loading mirror speeds from cached hostfile
    3. Loaded plugins: fastestmirror, langpacks, versionlock
    4. * extras: mirrors.aliyun.com
    5. docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable
    6. docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable
    7. docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable
    8. docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable
    9. docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable
    10. docker-ce.x86_64 3:20.10.4-3.el7 docker-ce-stable
    11. docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-stable
    12. docker-ce.x86_64 3:20.10.2-3.el7 docker-ce-stable
    13. docker-ce.x86_64 3:20.10.21-3.el7 docker-ce-stable
    14. docker-ce.x86_64 3:20.10.20-3.el7 docker-ce-stable
    15. docker-ce.x86_64 3:20.10.19-3.el7 docker-ce-stable
    16. docker-ce.x86_64 3:20.10.18-3.el7 docker-ce-stable
    17. docker-ce.x86_64 3:20.10.17-3.el7 docker-ce-stable
    18. docker-ce.x86_64 3:20.10.16-3.el7 docker-ce-stable
    19. docker-ce.x86_64 3:20.10.15-3.el7 docker-ce-stable
    20. docker-ce.x86_64 3:20.10.14-3.el7 docker-ce-stable
    21. docker-ce.x86_64 3:20.10.1-3.el7 docker-ce-stable
    22. docker-ce.x86_64 3:20.10.13-3.el7 docker-ce-stable
    23. docker-ce.x86_64 3:20.10.12-3.el7 docker-ce-stable
    24. docker-ce.x86_64 3:20.10.11-3.el7 docker-ce-stable
    25. docker-ce.x86_64 3:20.10.10-3.el7 docker-ce-stable
    26. docker-ce.x86_64 3:20.10.0-3.el7 docker-ce-stable
    27. .............................................................
    28. docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
    29. docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
    30. docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
    31. docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
    32. * base: mirrors.aliyun.com
    33. Available Packages

    我选择安装的版本是 3:20.10.21-3.el7版本

    yum install -y docker-ce-3:20.10.21-3.el7.x86_64

    1. Loaded plugins: fastestmirror, langpacks, versionlock
    2. Loading mirror speeds from cached hostfile
    3. * base: mirrors.aliyun.com
    4. * extras: mirrors.aliyun.com
    5. * updates: mirrors.aliyun.com
    6. Resolving Dependencies
    7. --> Running transaction check
    8. ---> Package docker-ce.x86_64 3:20.10.21-3.el7 will be installed
    9. .....................................
    10. Installed:
    11. docker-ce.x86_64 3:20.10.21-3.el7
    12. Dependency Installed:
    13. container-selinux.noarch 2:2.119.2-1.911c772.el7_8 containerd.io.x86_64 0:1.6.10-3.1.el7 docker-ce-cli.x86_64 1:20.10.21-3.el7 docker-ce-rootless-extras.x86_64 0:20.10.21-3.el7
    14. docker-scan-plugin.x86_64 0:0.21.0-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8
    15. Complete!

    5、启动docker

    systemctl start docker

    6、docker ps验证

    1. [root@dev-001 yum.repos.d]# docker ps
    2. CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES 

    7、设置开机自动启动

     systemctl enable docker

  • 相关阅读:
    jeesite添加多数据源
    大恒相机SDK开发
    JUC系列(四) callable与 常用的工具类
    基于JAVA的RSA文件加密软件的设计与实现
    Java方法概念/方法的定义与调用/形参与实参/方法的注意事项
    蓝桥杯第三场双周赛(AK)
    JNDI注入分析
    echarts-地图使用/配合散点图展示空气质量
    【JAVA】-- 简易超市管理系统窗口(三)(实现思路+每步代码)
    用go封装和实现扫码登录
  • 原文地址:https://blog.csdn.net/u012272367/article/details/128194633