zoukankan      html  css  js  c++  java
  • docker安装

    docker安装

    docker的基本组件

    docker的架构图

    image-20200909165754515

    镜像(images)

    Docker 镜像好比是一个模板 eg nginx 镜像 -----> run --------> nginx 容器(提供服务)

    容器(containers)

    Docker 通过容器技术 独立一个或者一个组的应用 通过镜像来创建的

    启动 停止 删除 等基本命令!

    可以将容器理解为一个简易的linux 系统

    仓库(registray)

    仓库就是存储镜像的!

    • 共有仓库

      dockerhub

      阿里云

    • 私有仓库

    安装docker

    环境准备

    1.准备一台centos7

    环境查看

    # 系统内核必须是3.0 以上的
    [root@localhost ~]# uname -r 
    3.10.0-862.el7.x86_64
    
    #查看系统版本
    [root@localhost ~]# uname -r 
    3.10.0-862.el7.x86_64
    [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"
    

    安装

    查看官方的帮助文档

    # 1. 卸载旧的版本
    $ sudo yum remove docker 
                      docker-client 
                      docker-client-latest 
                      docker-common 
                      docker-latest 
                      docker-latest-logrotate 
                      docker-logrotate 
                      docker-engine
                      
    # 2.需要的一些安装包
    $ sudo yum install -y yum-utils
    # 3.配置阿里云的镜像源
    $ sudo yum-config-manager 
        --add-repo 
        https://download.docker.com/linux/centos/docker-ce.repo   #(默认是国外的  非常慢)
        
    $ sudo yum-config-manager 
        --add-repo 
      	http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo  #推荐使用阿里云的
    # 4. 安装 docker 相关的包   docker-ce是社区版(一般安装社区版)  ee是企业版
    $ sudo yum install docker-ce docker-ce-cli containerd.io -y
    
    
    #默认是安装最新的版本
    $ yum list docker-ce --showduplicates | sort -r  #可以查看可用的版本
    docker-ce.x86_64            3:19.03.12-3.el7                   @docker-ce-stable
    docker-ce.x86_64            3:19.03.11-3.el7                   docker-ce-stable 
    docker-ce.x86_64            3:19.03.10-3.el7                   docker-ce-stable 
    docker-ce.x86_64            3:19.03.0-3.el7                    docker-ce-stable 
    docker-ce.x86_64            3:18.09.9-3.el7                    docker-ce-stable 
    $ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
    
    
    
    # 5. 启动
    
    [root@localhost ~]# systemctl start docker    # 启动服务
    [root@localhost ~]# systemctl enable docker   #开机自启动 避免重启服务器时 服务起不来
    Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
    
    # 6. 测试 hello-world
    [root@localhost ~]#	docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    0e03bdcc26d7: Pull complete 
    Digest: sha256:7f0a9f93b4aa3022c3a4c147a449bf11e0941a1fd0bf4a8e6c9408b2600777c5
    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/
    
    # 7.查看hello-world镜像
    

    image-20200909175638691

    # 8.查看hello-world容器
    

    image-20200909175808416

    #9.卸载docker
    $ sudo yum remove docker-ce docker-ce-cli containerd.io
    $ sudo rm -rf /var/lib/docker
    

    配置阿里云的镜像加速

    1、登录阿里云

    2、产品和服务

    image-20200910152301374

    Run 的流程和docker底层原理

    1.docker的run流程

    image-20200910153926801

    2.docker的底层原理

    Dokcer 是一个C/S 架构系统 docker守护进程是运行在宿主机上,通过socket从客户端访问

    DockerServer 通过DockerClient 指令会执行这个命令

    image-20200910155930871

    docker为什么比我们的VM快?

    1.docker比虚拟机更少抽象层

    image-20200910160700290

    2.新建一个docker不会像虚拟机一样重新加载一次内核能更好的避免引导所花费时间

    由此就能看出 传统虚拟机是分钟级 而docker是秒级的

    image-20200910161227745

    *************** 当你发现自己的才华撑不起野心时,就请安静下来学习吧!***************
  • 相关阅读:
    实验室网络管理记
    mondrian schema一个简单的例子
    powerdesigner数据库设计导入oracle9i
    linux 的mount命令
    [转]moto面试题
    Oracle数据库服务解释
    数据聚集技术在mondrian中的实现
    发现台湾的mondrian资料 + pentaho截图
    一个封装比较完整的FTP类(转载)
    oracle 网页管理工具登录接口
  • 原文地址:https://www.cnblogs.com/martin-huang/p/13680462.html
Copyright © 2011-2022 走看看