美文网首页
第四章 Docker命令汇总

第四章 Docker命令汇总

作者: 箫起秦楼 | 来源:发表于2018-11-23 20:36 被阅读0次

    请注意Docker新旧版本命令格式使用方法不同,但新版本兼容老版本的命令格式。
    本章只是做Docker命令汇总,看着如果比较枯燥,可以查看后续文章中的详细案例与介绍。
    在后续的文章中,会以实际案例对各个命令进行详细解释说明。

    Docker命令概述:

    # 命令行直接键入docker,查看docker命令文档:
    [root@centos_7_1]:[~]# docker
    # Docker客户端命令的用法:
    Usage:  docker [OPTIONS] COMMAND
    
    A self-sufficient runtime for containers
    # 选项:
    Options:
          --config string      Location of client config files (default "/root/.docker")
      -D, --debug              Enable debug mode
      -H, --host list          Daemon socket(s) to connect to
      -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
          --tls                Use TLS; implied by --tlsverify
          --tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")
          --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
          --tlskey string      Path to TLS key file (default "/root/.docker/key.pem")
          --tlsverify          Use TLS and verify the remote
      -v, --version            Print version information and quit
    # 新版本的Docker支持按分类查看命令:
    Management Commands:
      config      Manage Docker configs     # 管理Docker配置
      container   Manage containers         # 管理容器
      image       Manage images             # 管理镜像
      network     Manage networks           # 管理网络
      node        Manage Swarm nodes        # 
      plugin      Manage plugins            # 管理插件
      secret      Manage Docker secrets     # 
      service     Manage services           # 管理服务
      stack       Manage Docker stacks      # 
      swarm       Manage Swarm              #
      system      Manage Docker             # 管理Docker系统
      trust       Manage trust on Docker images     # 管理对Docker信任的镜像
      volume      Manage volumes            # 管理卷
    # 老版本命令:
    Commands:
      attach      Attach local standard input, output, and error streams 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 to files or directories 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 Docker objects
      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
      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 one or more containers
      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
      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
      tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
      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
      wait        Block until one or more containers stop, then print their exit codes
    
    Run 'docker COMMAND --help' for more information on a command.
    

    一、Docker容器命令

    # 查看Docker容器帮助文档:
    [root@centos_7_1]:[~]# docker container --help
    # Docker容器命令的用法:
    Usage:  docker container COMMAND
    
    Manage containers
    # 容器命令如下:
    Commands:
      attach      Attach local standard input, output, and error streams to a running container
      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 to files or directories on a container's filesystem
      exec        Run a command in a running container
      export      Export a container's filesystem as a tar archive
      inspect     Display detailed information on one or more containers
      kill        Kill one or more running containers
      logs        Fetch the logs of a container
      ls          List containers
      pause       Pause all processes within one or more containers
      port        List port mappings or a specific mapping for the container
      prune       Remove all stopped containers
      rename      Rename a container
      restart     Restart one or more containers
      rm          Remove one or more containers
      run         Run a command in a new container
      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
      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
      wait        Block until one or more containers stop, then print their exit codes
    
    Run 'docker container COMMAND --help' for more information on a command.
    

    二、Docker镜像命令

    [root@centos_7_1]:[~]# docker image --help
    
    Usage:  docker image COMMAND
    
    Manage images
    
    Commands:
      build       Build an image from a Dockerfile
      history     Show the history of an image
      import      Import the contents from a tarball to create a filesystem image
      inspect     Display detailed information on one or more images
      load        Load an image from a tar archive or STDIN
      ls          List images
      prune       Remove unused images
      pull        Pull an image or a repository from a registry
      push        Push an image or a repository to a registry
      rm          Remove one or more images
      save        Save one or more images to a tar archive (streamed to STDOUT by default)
      tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
    
    Run 'docker image COMMAND --help' for more information on a command.
    

    三、Docker网络命令

    [root@centos_7_1]:[~]# docker network --help
    
    Usage:  docker network COMMAND
    
    Manage networks
    
    Commands:
      connect     Connect a container to a network
      create      Create a network
      disconnect  Disconnect a container from a network
      inspect     Display detailed information on one or more networks
      ls          List networks
      prune       Remove all unused networks
      rm          Remove one or more networks
    
    Run 'docker network COMMAND --help' for more information on a command.
    

    Docker分类---文章目录:

    第一章 初识Docker | 点击此处
    第二章 安装Docker以及简单配置 | 点击此处
    第三章 Docker容器的生命周期 | 点击此处
    第四章 Docker命令汇总 | 点击此处
    第五章 Docker基础命令详解 | 点击此处
    第六章 Docker---镜像的命令详解 | 点击此处
    第七章 Docker---容器的命令详解 | 点击此处
    第八章 Docker与Alpine不解之缘 | 点击此处
    未完待续

    相关文章

      网友评论

          本文标题:第四章 Docker命令汇总

          本文链接:https://www.haomeiwen.com/subject/mfesqqtx.html