当容器内运行的应用想要获自身容器ID 时会用到该命令
cat /proc/self/cgroup | grep devices | grep -Po '[0-9a-z]{64}' | cut -c1-12
结合Docker 容器内执行宿主机命令获取容器自身容器名
_container_name=$(nsenter --mount=/host/1/ns/mnt docker inspect $(cat /proc/self/cgroup | grep devices | grep -Po '[0-9a-z]{64}' | cut -c1-12) -f '{{.Name}}' | sed 's,/,,')
Docker inspect
nsenter --mount=/host/1/ns/mnt docker inspect $(cat /proc/self/cgroup | grep devices | grep -Po '[0-9a-z]{64}' | cut -c1-12)