dockerÔõôÍ˳öÒ»¸öÈÝÆ÷
Í˳ö docker ÈÝÆ÷µÄÒªÁìÓУºÊ¹Óà docker cli Í˳öÏÂÁdocker stop£©£¬·¢ËÍ sigterm ÐźŸøÈÝÆ÷²¢ÆÚ´ý 10 ÃëÍËÈ´³ö¡£Í¨¹ý docker api Í˳öÈÝÆ÷£¬Ê¹Óà post ÇëÇó²¢Ö¸¶¨ stop ²ÎÊýΪ true¡£Ç¿ÖÆÍ˳öÈÝÆ÷£¨docker stop -t 0£©£¬Á¬Ã¦¹Ø±ÕÈÝÆ÷ ???·¢ËÍ sigterm Ðźš£
Í˳ö Docker ÈÝÆ÷
ÒªÍ˳ö Docker ÈÝÆ÷£¬¿ÉÒÔʹÓÃÒÔÏÂÒªÁ죺
ʹÓà Docker CLI Í˳öÏÂÁî
Äú¿ÉÒÔʹÓà docker stop ÏÂÁºó¸úÈÝÆ÷µÄ ID »òÃû³Æ£º
docker stop <container-id-or-name></container-id-or-name>
µÇ¼ºó¸´ÖÆ
ʹÓà Docker API Í˳öÏÂÁî
Äú»¹¿ÉÒÔͨ¹ý Docker API Í˳öÈÝÆ÷¡£Ê¹ÓÃÒÔÏ cURL ÏÂÁ
curl -X POST -H "Content-Type: application/json" -d '{"Stop": true}' http://localhost:2375/containers/<container-id-or-name>/stop</container-id-or-name>
µÇ¼ºó¸´ÖÆ
×¢ÖØ£º docker stop ÏÂÁ·¢ËÍ SIGTERM ÐźŸøÈÝÆ÷¡£ÈôÊÇÄúÏ£ÍûÁ¬Ã¦¹Ø±ÕÈÝÆ÷£¬¿ÉÒÔʹÓà docker kill ÏÂÁî¡£
Í˳öÈÝÆ÷µÄÏêϸÐÅÏ¢
Á¬Ã¦Í˳ö£¨docker kill£©£ºÊ¹Óà docker kill ÏÂÁºó¸úÈÝÆ÷µÄ ID »òÃû³Æ£¬½«Á¬Ã¦¹Ø±ÕÈÝÆ÷¶ø²»»á·¢ËÍ SIGTERM Ðźţº
docker kill <container-id-or-name></container-id-or-name>
µÇ¼ºó¸´ÖÆ
ÓÅÑŵØÍ˳ö£¨docker stop£©£ºÊ¹Óà docker stop ÏÂÁî»áÏòÈÝÆ÷·¢ËÍ SIGTERM Ðźţ¬¸øÓèÈÝÆ÷ʱ¼äÖ´ÐÐÈκÎÐëÒªµÄÕûÀí²Ù×÷¡£ÈÝÆ÷½«ÔÚÊÕµ½ SIGTERM ÐźźóµÄ 10 ÃëÄÚÍ˳ö¡£
Ç¿ÖÆÍ˳ö£¨docker stop -t 0£©£ºÍ¨¹ýÖ¸¶¨ -t 0 Ñ¡Ïîµ½ docker stop ÏÂÁÄú¿ÉÒÔÁ¬Ã¦¹Ø±ÕÈÝÆ÷£¬¶øÎÞÐè·¢ËÍ SIGTERM Ðźš£
Ñ¡ÔñÍ˳öÒªÁì
Ñ¡ÔñÍ˳öÒªÁìÈ¡¾öÓÚÄúµÄÏêϸÐèÇó£º
ÓÅÑŵØÍ˳ö£ºÈôÊÇÄúÏ£ÍûÈÝÆ÷ÔÚÍ˳öÇ°Ö´ÐÐÈκÎÕûÀí²Ù×÷£¬ÇëʹÓà docker stop ÏÂÁî¡£
Á¬Ã¦Í˳ö£ºÈôÊÇÄúÏ£ÍûÁ¬Ã¦¹Ø±ÕÈÝÆ÷£¬ÇëʹÓà docker kill ÏÂÁî¡£
Ç¿ÖÆÍ˳ö£ºÈôÊÇÄúÏ£ÍûÈÝÆ÷Á¬Ã¦¹Ø±Õ£¬¶ø²»Ö´ÐÐÈκÎÕûÀí²Ù×÷£¬ÇëʹÓà docker stop -t 0 ÏÂÁî¡£
ÒÔÉϾÍÊÇdockerÔõôÍ˳öÒ»¸öÈÝÆ÷µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡