zoukankan      html  css  js  c++  java
  • docker简单介绍

    1.直接在终端输入docker会返回docker支持的所有命令和一些通用的参数,如下

    Usage: docker [OPTIONS] COMMAND [arg...]
           docker [ --help | -v | --version ]
    
    A self-sufficient runtime for containers.
    
    Options:
    
      --config=~/.docker              Location of client config files
      -D, --debug                     Enable debug mode
      -H, --host=[]                   Daemon socket(s) to connect to
      -h, --help                      Print usage
      -l, --log-level=info            Set the logging level
      --tls                           Use TLS; implied by --tlsverify
      --tlscacert=~/.docker/ca.pem    Trust certs signed only by this CA
      --tlscert=~/.docker/cert.pem    Path to TLS certificate file
      --tlskey=~/.docker/key.pem      Path to TLS key file
      --tlsverify                     Use TLS and verify the remote
      -v, --version                   Print version information and quit
    
    Commands:
        attach    Attach to a running container
        build     Build an image from a Dockerfile
        commit    Create a new image from a container's changes
        cp        Copy files/folders between a container and the local filesystem
        create    Create a new container
        diff      Inspect changes on a container's filesystem
        events    Get real time events from the server
        exec      Run a command in a running container
        export    Export a container's filesystem as a tar archive
        history   Show the history of an image
        images    List images
        import    Import the contents from a tarball to create a filesystem image
        info      Display system-wide information
        inspect   Return low-level information on a container, image or task
        kill      Kill one or more running containers
        load      Load an image from a tar archive or STDIN
        login     Log in to a Docker registry.
        logout    Log out from a Docker registry.
        logs      Fetch the logs of a container
        network   Manage Docker networks
        node      Manage Docker Swarm nodes
        pause     Pause all processes within one or more containers
        port      List port mappings or a specific mapping for the container
        ps        List containers
        pull      Pull an image or a repository from a registry
        push      Push an image or a repository to a registry
        rename    Rename a container
        restart   Restart a container
        rm        Remove one or more containers
        rmi       Remove one or more images
        run       Run a command in a new container
        save      Save one or more images to a tar archive (streamed to STDOUT by default)
        search    Search the Docker Hub for images
        service   Manage Docker services
        start     Start one or more stopped containers
        stats     Display a live stream of container(s) resource usage statistics
        stop      Stop one or more running containers
        swarm     Manage Docker Swarm
        tag       Tag an image into a repository
        top       Display the running processes of a container
        unpause   Unpause all processes within one or more containers
        update    Update configuration of one or more containers
        version   Show the Docker version information
        volume    Manage Docker volumes
        wait      Block until a container stops, then print its exit code
    
    Run 'docker COMMAND --help' for more information on a command.
    View Code

    2.在控制台执行docker 命令 --help  例如:docker start --help 会列出docker start命令支持的所有参数

    Usage:    docker start [OPTIONS] CONTAINER [CONTAINER...]
    
    Start one or more stopped containers
    
    Options:
      -a, --attach               Attach STDOUT/STDERR and forward signals
          --detach-keys string   Override the key sequence for detaching a container
          --help                 Print usage
      -i, --interactive          Attach container's STDIN
    View Code

    3.使用man命令来查看docker命令支持的参数,例如: man docker start

    Docker在LCX的基础上做了什么呢

    LXC用户态工具(https://github.com/lxc/lxc)

    Linux Container,即内核容器技术的简称

    我们这里一般指的是内核容器技术的简称,简单的说,就是docker在内核容器技术(Cgroup和Namespace)的基础上,提供了一个更高层的控制工具,该工具包含以下特征

      1.跨主机部署:docker定义了镜像格式,该格式会将应用程序和其所依赖的文件打包到同一个镜像文件中,从而使其在转移到任何运行docker的机器中时都可以运行,并能够保证在任何机器中该应用程序执行的环境都是一样的。LXC实现了“进程沙盒”这一重要特性是跨主机部署的前提条件,单是只有这一点还远远不够,比如,在一个特定的LXC配置下执行应用程序,将应用程序打包并拷贝到另一个LXC环境下,程序很有可能无法正常执行,因为该程序的执行依赖于该机器的特定配置,包括网卡、存储、发行版等。而docker则将上述相关配置进行抽象并与应用程序一同打包,所以可以保证在不同的硬件、不同配置的机器上docker容器中运行的程序和其所依赖的环境及配置是一致的。

      2.以应用为中心:docker为简化应用程序的部署过程做了很多优化,这一目的在docker的API、用户接口、设计哲学和用户文档中都有体现,其dockerfile机制大大简化和规范了应用的部署方法

      3.自动构建:docker提供了一套能够从源码自动构建镜像的工具,该工具可以灵活地使用make、maven、chef、puppet、salt、debian包、RPM和源码包等形式,将应用程序的依赖、构建工具和安装包进行打包处理,而且当前机器的配置不会影响镜像的构建过程

      4.版本管理:docker提供了类似于git的版本管理功能,支持追踪镜像版本、检验版本更新、提交新的版本改动和回退版本等功能。镜像的版本信息中包括制作方式和制作者信息,因此可以从生产环境中回溯到上游开发人员。docker同样实现了镜像的增量上传下载功能,用户可以通过获取新旧版本之间新增的镜像层来更新镜像版本,而不必下载完成镜像,类似于git中的pull命令。

      5.组件重用:任何容器都可以用作生成另一个组件的基础镜像。这一过程可以手动执行,也可以写入自动化构建的脚本。例如,可以创建一个包含python开发环境的镜像,并将其作为基础镜像部署其它使用python环境进行开发的应用程序

      6.共享:docker用户可以访问公共的镜像registry,并向其中上传有用的镜像。Registry中同样包含由docker公司维护的一些官方标准镜像。docker Registry本身也是开源的,所以任何人都可以部署自己的仓库来存储并共享私有镜像

      7.工具生态链:docker定义了一系列API来定制容器的创建和部署过程并实现自动化,有很多工具能够与docker集成并扩展docker的能力,包括类PaaS部署工具(dokku、deis和flynn)、多节点编排工具(masetro、salt、mesos、openstack nova)、管理面板(docker-ui、openstack Horizon、shipyard)、配置管理工具(chef、puppet)、持续集成工具(Jenkins、strider、travis)等。docker正在建立以容器为基础的工具集标准

    docker容器和虚拟机之间的区别

    虚拟机:是用来进行硬件资源划分的完美解决方案,它利用了硬件虚拟化技术,例如 VT-x、AMD-v或者privilege level(权限等级)会同时通过一个hypervison层来实现对资源的彻底隔离

    docker:容器是操作系统级别的虚拟化,利用内核的Cgroup和Namespace特性,此功能完全通过软件来实现。仅仅是进程本身就可以与其他进程隔离开,不需要任何辅助

    区别:docker属于轻量级的,可以在linux机器上运行100多个docker容器甚至更多,并且不会占用太多的系统资源(如果容器中没有执行运算任何或者IO操作);docker启动很快,秒级或者毫秒级别的,而单台物理机上不可能创建100台虚拟机,因为每一个虚拟机实例都会占用一个完整的操作系统所需要的所有资源,虚拟机启动虽然比物理机快,但是启动起来也需要数秒到数十秒

    选择容器还是虚拟化:需要安全隔离可以使用虚拟机,如果想要隔离进行并且需要运行大量进行实例,则应该选择docker容器

    容器的组成

      容器=cgroup+namespace+rootfs+容器引擎(用户态工具)

      功能:

      cgroup:资源控制

      namespace:访问隔离

      rootfs:文件系统隔离

      容器引擎:生命周期控制

     

  • 相关阅读:
    Docker login报错一例
    Ubuntu 18.04设置dns
    docker日志引擎说明
    Docker简介与安装配置
    使用traefik作为kubernetes的ingress
    Axiom3D:Ogre动画基本流程与骨骼动画
    Axiom3D:Ogre中Mesh文件格式分析(一)
    Axiom3D:数据绑定基本流程
    3D引擎Axiom的选择与学习.
    初试PyOpenGL四 (Python+OpenGL)GPU粒子系统与基本碰撞
  • 原文地址:https://www.cnblogs.com/python-cat/p/8459074.html
Copyright © 2011-2022 走看看