• centos7下docker的安装


    背景

    总结下docker的一些知识

    docker安装(有网络版)

    参考文章我以前试过这个帖子,建议安装高版本的docker,(20以上的,不然可能会有一些问题)

    ## 1、安装依赖
    [root@iZo7e61fz42ik0Z ~]#yum install -y yum-utils device-mapper-persistent-data lvm2
    ## 2、添加docker软件源
    [root@iZo7e61fz42ik0Z ~]#yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    ## 3、只保留稳定版本
    [root@iZo7e61fz42ik0Z ~]#yum-config-manager --disable docker-ce-edge
    [root@iZo7e61fz42ik0Z ~]#yum-config-manager --disable docker-ce-test
    ## 4、更新包索引
    [root@iZo7e61fz42ik0Z ~]#yum makecache fast
    ## 5、更新yum包索引
    [root@iZo7e61fz42ik0Z ~]#yum list docker-ce --showduplicates|sort -r
    Loading mirror speeds from cached hostfile
    Loaded plugins: fastestmirror
    Installed Packages
    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.1.ce-3.el7                   @docker-ce-stable
    docker-ce.x86_64            18.06.0.ce-3.el7                   docker-ce-stable
    docker-ce.x86_64            18.03.1.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            18.03.0.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            17.12.1.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            17.12.0.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            17.09.1.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            17.09.0.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            17.06.2.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            17.06.1.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            17.06.0.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            17.03.3.ce-1.el7                   docker-ce-stable
    docker-ce.x86_64            17.03.2.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable
    docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable
    Available Packages
    # 安装指定版本
    [root@iZo7e61fz42ik0Z ~]#yum -y install docker-ce-18.06.1.ce
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34

    Docker安装完毕,启动Docker服务查看一下版本

    # 启动docker
    [root@iZo7e61fz42ik0Z ~]#systemctl start docker
    # 开机自启
    [root@iZo7e61fz42ik0Z ~]#systemctl enable docker
    # 查看版本
    [root@iZo7e61fz42ik0Z ~]# docker version
    Client:
     Version:           18.06.1-ce
     API version:       1.38
     Go version:        go1.10.3
     Git commit:        e68fc7a
     Built:             Tue Aug 21 17:23:03 2018
     OS/Arch:           linux/amd64
     Experimental:      false
    
    Server:
     Engine:
      Version:          18.06.1-ce
      API version:      1.38 (minimum version 1.12)
      Go version:       go1.10.3
      Git commit:       e68fc7a
      Built:            Tue Aug 21 17:25:29 2018
      OS/Arch:          linux/amd64
      Experimental:     false
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    docker安装(无网络版)

    • 提前下载docker,下载docker的安装文件:https://download.docker.com/linux/static/stable/x86_64/
    • 开始安装
    docker  安装,这里我下载的19.03.9,后续就出现了一些端口安全的问题
    #   解压docker 安装包
    tar -zxvf docker-19.03.9.tgz
    #  解压文件移动到到 /usr/bin
    mv docker/* /usr/bin/ 
    # 配置docker.service 文件
    cd /etc/systemd/system/
    # 把离线部署里的docker.service文件传到这个目录
    可以使用sftp,或者rz命令   
    # 赋予执行权限
    chmod +x /etc/systemd/system/docker.service     
    # 重新加载配置文件
    systemctl daemon-reload
    # 开机自启
    systemctl enable docker.service                                          
    # 启动docker
    systemctl start docker   
    #查看docker版本
     docker -v        
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • docker.service文件
    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network-online.target firewalld.service
    Wants=network-online.target
      
    [Service]
    Type=notify
    # the default is not to use systemd for cgroups because the delegate issues still
    # exists and systemd currently does not support the cgroup feature set required
    # for containers run by docker
    ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
    ExecReload=/bin/kill -s HUP
    # Having non-zero Limit*s causes performance problems due to accounting overhead
    # in the kernel. We recommend using cgroups to do container-local accounting.
    LimitNOFILE=infinity
    LimitNPROC=infinity
    LimitCORE=infinity
    # Uncomment TasksMax if your systemd version supports it.
    # Only systemd 226 and above support this version.
    #TasksMax=infinity
    TimeoutStartSec=0
    # set delegate yes so that systemd does not reset the cgroups of docker containers
    Delegate=yes
    # kill only the docker process, not all processes in the cgroup
    KillMode=process
    # restart the docker process if it exits prematurely
    Restart=on-failure
    StartLimitBurst=3
    StartLimitInterval=60s
      
    [Install]
    WantedBy=multi-user.target
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
  • 相关阅读:
    电脑分辨率怎么调?电脑分辨率怎么调合适
    13. 用Rust手把手编写一个wmproxy(代理,内网穿透等), HTTP中的压缩gzip,deflate,brotli算法
    JVM-五大区
    OpenAI的Whisper蒸馏:蒸馏后的Distil-Whisper速度提升6倍
    数据库:常用数据库的创建
    【Leetcode】200.岛屿数量
    数据库视图的基本操作(sql语句)
    JAVA-----注释、字面量、关键字、制表符
    Java项目:快递取件管理系统(java+SSM+JSP+jQuery+Mysql)
    基于springboot实现家具商城管理系统项目【项目源码】计算机毕业设计
  • 原文地址:https://blog.csdn.net/GDFHGFHGFH/article/details/136192605