Python从Docker contain内部获取Docker容器名称

2024-05-17 19:45:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要从python中运行的容器中获取容器名称

我可以很容易地从python中的容器内部获取容器id

bashCommand = """head -1 /proc/self/cgroup|cut -d/ -f3"""
output = subprocess.check_output(['bash','-c', bashCommand])
print output

现在我需要集装箱名称


Tags: self名称bashidoutputcheckprochead