• Docker的部署安装(CentOS)-by paymob


    环境准备

    通过命令查看系统版本和内核版本等信息

    [gmuser@172-16-76-120 ~]$ cat /etc/redhat-release
    CentOS Linux release 7.2.1511 (Core)
    [gmuser@172-16-76-120 ~]$ uname -a
    Linux 172-16-76-120 3.10.0-327.18.2.el7.x86_64 #1 SMP Thu May 12 11:03:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
    [gmuser@172-16-76-120 ~]$ cat /etc/os-release
    NAME="CentOS Linux"
    VERSION="7 (Core)"
    ID="centos"
    ID_LIKE="rhel fedora"
    VERSION_ID="7"
    PRETTY_NAME="CentOS Linux 7 (Core)"
    ANSI_COLOR="0;31"
    CPE_NAME="cpe:/o:centos:centos:7"
    HOME_URL="https://www.centos.org/"
    BUG_REPORT_URL="https://bugs.centos.org/"
    CENTOS_MANTISBT_PROJECT="CentOS-7"
    CENTOS_MANTISBT_PROJECT_VERSION="7"
    REDHAT_SUPPORT_PRODUCT="centos"
    REDHAT_SUPPORT_PRODUCT_VERSION="7"

    为用户提权(sudo)

    [gmuser@172-16-76-120 ~]$ sudo install
    [sudo] password for gmuser:
    Sorry, try again.
    
    [sudo] password for gmuser:
    gmuser is not in the sudoers file.  This incident will be reported.
    [gmuser@172-16-76-120 ~]$ su root
    
    Password:
    [root@172-16-76-120 gmuser]# vim /etc/sudoers
     
    
    ## Allow root to run any commands anywhere
    
    root    ALL=(ALL)       ALL
    
    gmuser  ALL=(ALL)       ALL
    
    ## Allows members of the 'sys' group to run networking, software,
    
    ## service management apps and more.
    
    # %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
    
     
    
    ## Allows people in group wheel to run all commands
    
     

    保存退出

    操作系统需求



    为兼容企业级应用,学习选用Centos7做为部署安装Docker的系统平台

     

    更换默认的yum源

    Centos默认的yun源在国外,速度很慢有时间也无法访问

    [gmuser@172-16-76-120 ~]$ yum repolist
    
    [gmuser@172-16-76-120 ~]$ vi /etc/hosts  
    
    [gmuser@172-16-76-120 ~]$ ping mirrors.aliyun.com
    
    更换成aliyun yum 源
    
    [root@172-16-76-120 /]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
    
    [root@172-16-76-120 /]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    
    [root@172-16-76-120 /]# vi /etc/yum.repos.d/CentOS-Base.repo

    Yum运行下面的命令生成缓存

    [root@172-16-76-120 /]# yum clean all
    Loaded plugins: fastestmirror, langpacks
    Cleaning repos: base epel extras updates
    Cleaning up everything
    Cleaning up list of fastest mirrors
    [root@172-16-76-120 /]# yum makecache
    [root@172-16-76-120 /]# yum repolist

    删除docker旧版本

    [gmuser@172-16-76-120 /]$ sudo yum remove docker docker-common docker-selinux docker-engine
    [sudo] password for gmuser:
    Loaded plugins: fastestmirror, langpacks
    No Match for argument: docker
    No Match for argument: docker-common
    No Match for argument: docker-selinux
    No Match for argument: docker-engine
    No Packages marked for removal

    安装 Docker CE

    [gmuser@172-16-76-120 /]$ sudo yum remove docker docker-common docker-selinux docker-engine
    [gmuser@172-16-76-120 /]$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    [gmuser@172-16-76-120 /]$ sudo yum install -y docker-ce

    若需要安装指定的版本时,可参照以下命令

    启动docker

    [gmuser@172-16-76-120 /]$ sudo systemctl start docker
    [gmuser@172-16-76-120 /]$ sudo docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    
    [gmuser@172-16-76-120 /]$

    升级和卸载docker

    使用阿里镜像加速器

    使用阿里云专属加速器加快获取Docker官方镜像,否则在国内速度会慢到你无法忍受哒。步骤如下:

    1. 免费注册一个阿里云账号 www.aliyun.com
    2. 进入加速器页面 https://cr.console.aliyun.com/#/accelerator
    3. 选择镜像加速器

    按图中进行相关配置

     

    参考文档:

  • 相关阅读:
    B507实验室打印机连接方法
    2016年武汉大学计算机学院“新技术系列讲座”简介记录
    使用SpringBoot快速构建应用程序
    UIColor,CGColor,CIColor三者的区别和联系
    Objective C中NULL、Nil、nil、NSNull 的区别
    iOS 部分机制
    常见排序算法-采用Objective-c实现
    iOS的永久存储
    网络协议初探
    iOS多线程编程之Grand Central Dispatch(GCD)介绍和使用
  • 原文地址:https://www.cnblogs.com/duwamish/p/11028844.html
Copyright © 2020-2023  润新知