zoukankan      html  css  js  c++  java
  • 根据进程id pid 查容器id

    To get container ID you can use:

    cat /proc/<process-pid>/cgroup
    

    Then to convert the container ID to docker container name:

    docker inspect --format '{{.Name}}' "${containerId}" | sed 's/^///'
    

    以下是例子

    [root@nodejs1 ~]# cat /proc/68069/cgroup 
    11:pids:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    10:hugetlb:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    9:perf_event:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    8:devices:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    7:freezer:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    6:net_prio,net_cls:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    5:cpuacct,cpu:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    4:cpuset:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    3:blkio:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    2:memory:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    1:name=systemd:/system.slice/docker-f66fdd05b0780e9914a32ab3594259a66a49d7f18c7eca9f4d60d93d63bdf2d7.scope
    [root@nodejs1 ~]# docker inspect --format '{{.Name}}' "f66f" | sed 's/^///'
    shebao.1.hx50qn3yaahmm03nybc1fwcyr
    
  • 相关阅读:
    react的CSS中 :global的含义
    TypeScript中的问号 ? 与感叹号 ! 的含义
    移动端1px问题的解决方案
    原生js实现call,apply以及bind
    哪些场景不能使用箭头函数
    线性渐变、径向渐变以及圆锥渐变
    vue 开发中实现provide和inject实现依赖注入
    inline-block元素去除间隙
    clientWidth、offsetWidth、scrollWidth的区别
    session、token和cookie
  • 原文地址:https://www.cnblogs.com/fsckzy/p/11849882.html
Copyright © 2011-2022 走看看