• Docker-ce的安装及其卸载


    Docker的安装

    环境准备

    • 需要会Linux基础
    • 需要一台CentOS 7
    • 需要连接CentOS 7执行指令,并且能联网

    安装:

    连接服务器

     查看环境,内核是否为3.8以上的

    [root@localhost ~]# uname -a
    Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

    查看系统版本,最好为CentOS 7

    [root@localhost ~]# 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"

    卸载旧版本的Docker,我的因为没有所以 不会卸载

    [root@localhost ~]# yum remove docker 
    >                   docker-client 
    >                   docker-client-latest 
    >                   docker-common 
    >                   docker-latest 
    >                   docker-latest-logrotate 
    >                   docker-logrotate 
    >                   docker-engine
    ;
    已加载插件:fastestmirror
    参数 docker 没有匹配
    参数 docker-client 没有匹配
    参数 docker-client-latest 没有匹配
    参数 docker-common 没有匹配
    参数 docker-latest 没有匹配
    参数 docker-latest-logrotate 没有匹配
    参数 docker-logrotate 没有匹配
    参数 docker-engine 没有匹配
    不删除任何软件包
    [root@localhost ~]# 

    安装yum-utils

    [root@localhost ~]# yum install -y yum-utils

    设置镜像的仓库

    国外的

    yum-config-manager 
        --add-repo 
        https://download.docker.com/linux/centos/docker-ce.repo

    阿里云的 建议采用

    yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

    更新软件包索引

    [root@localhost ~]# yum makecache fast

    安装Docker 引擎 客户端 容器IO 注意:-ce 代表社区版 -ee是企业版

    [root@localhost ~]# yum install docker-ce docker-ce-cli containerd.io

    如果需要安装指定版本的Docker-ce,可以看这个命令

    搜索版本
    yum list docker-ce --showduplicates | sort -r
    指定版本
    yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

    我直接安装的最新版

    启动Docker

    [root@localhost ~]# systemctl start docker

    查看Docker版本,能打印出信息代表Docker安装成功

    [root@localhost ~]# docker version

    测试,运行hello-world镜像

    [root@localhost ~]# docker run hello-world
    Unable to find image 'hello-world:latest' locally 本地没有找到名字为hello-world:latest的镜像
    latest: Pulling from library/hello-world 去远程库拉取镜像
    0e03bdcc26d7: Pull complete 拉取成功
    Digest: sha256:95ddb6c31407e84e91a986b004aee40975cb0bda14b5949f6faac5d2deadb4b9 校验码
    Status: Downloaded newer image for hello-world:latest 
      开始执行镜像
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
     https://hub.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/get-started/

    查看本地镜像

    [root@localhost ~]# docker images
    REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
    hello-world   latest    bf756fb1ae65   13 months ago   13.3kB

    到此安装成功

    卸载:

    卸载Docker的引擎 cli 和容器

    yum remove docker-ce docker-ce-cli containerd.io

    主机上的镜像,容器,卷或自定义配置文件不会自动删除。要删除所有图像,容器和卷

    rm -rf /var/lib/docker

    作者:彼岸舞

    时间:2021218

    内容关于:Docker

    本文来源于网络,只做技术分享,一概不负任何责任

  • 相关阅读:
    10年学到的编程经验总结
    高效阅读源代码指南
    一行代码解决各种IE兼容问题,IE6,IE7,IE8,IE9,IE10
    如何用git将项目代码上传到github
    关于[].slice.call(arguments, 1) 的思考
    前端笔试题(一)
    2017年第一波JavaScript前端面试题
    2017前端面试题之综合篇(1)
    2017前端面试题之Js篇(1)
    前后端分离后各自职责
  • 原文地址:https://www.cnblogs.com/flower-dance/p/14411501.html
Copyright © 2020-2023  润新知