dockerÈÝÆ÷idÔõô²é
docker ÈÝÆ÷ id ¿ÉÓÃÓÚ±êʶºÍÖÎÀíÈÝÆ÷¡£ÒÔÏÂÊDzéÕÒ id µÄËÄÖÖÒªÁ죺ÁгöÕýÔÚÔËÐеÄÈÝÆ÷£ºdocker psͨ¹ýÈÝÆ÷Ãû³Æ²éÕÒ id£ºdocker ps -a | grep “container name”ͨ¹ý¾µÏñÃû³Æ²éÕÒ id£ºdocker ps -a | grep “image name”ʹÓà docker api£ºcurl -x get http://localhost:2375/containers/json | jq -r ‘.[].id’
ÔõÑùÔÚ Docker ÖвéÕÒÈÝÆ÷ ID
Docker ÈÝÆ÷ ID ÊÇÒ»¸öΨһµÄ±êʶ·û£¬ÓÃÓÚʶ±ðºÍÖÎÀíÕýÔÚÔËÐлò×èÖ¹µÄÈÝÆ÷¡£ÒÔÏÂÊÇÔÚ Docker ÖвéÕÒÈÝÆ÷ ID µÄ°ì·¨£º
1. ÁгöÕýÔÚÔËÐеÄÈÝÆ÷
ʹÓà docker ps ÏÂÁî¿ÉÒÔÁгöÕýÔÚÔËÐеÄÈÝÆ÷£º
docker ps
µÇ¼ºó¸´ÖÆ
Êä³öÖн«ÏÔʾÒÔÏÂÁУº
CONTAINER ID
IMAGE
COMMAND
CREATED
STATUS
PORTS
NAMES
2. ͨ¹ýÈÝÆ÷Ãû³Æ²éÕÒÈÝÆ÷ ID
ÈôÊÇÖªµÀÈÝÆ÷Ãû³Æ£¬¿ÉÒÔʹÓà docker ps -a ÏÂÁî²éÕÒÈÝÆ÷ ID£¬ÆäÖÐ -a Ñ¡ÏîÁгöËùÓÐÈÝÆ÷£¬°üÀ¨ÒÑ×èÖ¹µÄÈÝÆ÷£º
docker ps -a | grep "CONTAINER NAME"
µÇ¼ºó¸´ÖÆ
3. ͨ¹ý¾µÏñÃû³Æ²éÕÒÈÝÆ÷ ID
ÈôÊÇÖªµÀ¾µÏñÃû³Æ£¬¿ÉÒÔʹÓà docker ps -a | grep “IMAGE NAME” ÏÂÁî²éÕÒÈÝÆ÷ ID£º
docker ps -a | grep "IMAGE NAME"
µÇ¼ºó¸´ÖÆ
4. ʹÓà Docker API ²éÕÒÈÝÆ÷ ID
Ò²¿ÉÒÔʹÓà Docker API ²éÕÒÈÝÆ÷ ID£º
curl -X GET http://localhost:2375/containers/json | jq -r '.[].Id'
µÇ¼ºó¸´ÖÆ
Êä³ö½«ÊÇËùÓÐÈÝÆ÷ ID µÄÁÐ±í¡£
ÒÔÉϾÍÊÇdockerÈÝÆ÷idÔõô²éµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡