How do I list all containers in a user-defined docker network?

后端 未结 6 1667
刺人心
刺人心 2021-02-04 08:12

How do I get a list of all the containers in a user-defined docker network?

I would like to get all the commit hashes of every container for a specific user-defined dock

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-04 08:34

    This is my bash command using python's json parsing

    docker network inspect YOUR_NETWORK_ID \
        | python -c "import sys, json; print([v['Name'] for k,v in json.load(sys.stdin)[0]['Containers'].items()])"
    

    Sample output

    [u'container1', u'container2']
    

提交回复
热议问题