zoukankan      html  css  js  c++  java
  • docker基础:容器操作命令

    blog:https://www.cnblogs.com/Rohn/

    容器操作

    • docker ps:列出容器;
    • docker inspect:获取容器/镜像的元数据;
    • docker top:查看容器中运行的进程信息;
    • docker events:从服务器获取实时事件;
    • docker logs:获取容器的日志;
    • docker wait:阻塞运行直到容器停止,然后打印出它的退出代码;
    • docker export:将文件系统作为一个tar归档文件导出到STDOUT;
    • docker port:列出指定的容器的端口映射,或者查找将PRIVATE_PORT NAT到面向公众的端口;
    • docker stats:显示容器资源使用情况统计信息的实时流;

    列出容器

    语法如下:

    docker ps [OPTIONS]
    
    Options:
      -a, --all             Show all containers (default shows just running)
      -f, --filter filter   Filter output based on conditions provided
          --format string   Pretty-print containers using a Go template
          --help            Print usage
      -n, --last int        Show n last created containers (includes all states) (default -1)
      -l, --latest          Show the latest created container (includes all states)
          --no-trunc        Don't truncate output
      -q, --quiet           Only display numeric IDs
      -s, --size            Display total file sizes
    

    获取容器/镜像的元数据

    语法如下:

    docker inspect [OPTIONS] NAME|ID [NAME|ID...]
    
    Options:
      -f, --format string   Format the output using the given Go template
          --help            Print usage
      -s, --size            Display total file sizes if the type is container
          --type string     Return JSON for specified type
    

    查看容器中运行的进程信息

    语法如下:

    docker top CONTAINER [ps OPTIONS]
    

    获取事件

    语法如下:

    docker events [OPTIONS]
    
    Options:
      -f, --filter filter   Filter output based on conditions provided
          --format string   Format the output using the given Go template
          --since string    Show all events created since timestamp
          --until string    Stream events until this timestamp
    

    获取日志

    语法如下:

    docker logs [OPTIONS] CONTAINER
    
    Options:
          --details        Show extra details provided to logs
      -f, --follow         Follow log output
          --since string   Show logs since timestamp
          --tail string    Number of lines to show from the end of the logs (default "all")
      -t, --timestamps     Show timestamps
    

    阻塞运行

    语法如下:

    docker wait CONTAINER [CONTAINER...]
    

    导出容器

    语法如下:

    docker export [OPTIONS] CONTAINER
    
    Options:
      -o, --output string   Write to a file, instead of STDOUT
    

    端口映射

    语法如下:

    docker port CONTAINER [PRIVATE_PORT[/PROTO]]
    

    显示资源使用

    语法如下:

    docker stats [OPTIONS] [CONTAINER...]
    
    Options:
      -a, --all             Show all containers (default shows just running)
          --format string   Pretty-print images using a Go template
          --no-stream       Disable streaming stats and only pull the first result
    
  • 相关阅读:
    memcache的最佳实践方案。
    ehcache memcache redis 三大缓存男高音
    微服务-----(网站架构演变)
    分布式job-任务调度(一)
    rocketmq(三 java操作rocket API, rocketmq 幂等性)
    rocketMQ(二 )Centos7 集群
    go基础三 数组,切片,map,list
    go语言基础二 函数 ,递归函数 ,指针
    go语言基础一:数据类型,变量和常量,类型转化
    Spring AOP 学习(一) 代理模式
  • 原文地址:https://www.cnblogs.com/Rohn/p/13303538.html
Copyright © 2011-2022 走看看