📜  从名称中获取 docker id - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:49:55.194000             🧑  作者: Mango

代码示例1
In Linux:

$ sudo docker ps -aqf "name=containername"

Or in OS X, Windows:

$ docker ps -aqf "name=containername"


where containername is your container name.
To avoid getting false positives, you can use regex anchors like so:
docker ps -aqf "name=^containername$"

explanation:
    -q for quiet. output only the ID
    -a for all. works even if your container is not running
    -f for filter.
    ^ container name must start with this string
    $ container name must end with this string