dockerÔõÑù½øÈëÈÝÆ÷
½øÈë docker ÈÝÆ÷ÐèÒªÖ´ÐÐÒÔÏ°취£º·¿ªÖն˴°¿Ú¡£Ê¹Óà docker ps ÏÂÁîÉó²éÕýÔÚÔËÐеÄÈÝÆ÷¡£Ê¹Óà docker exec -it /bin/bash ÏÂÁî½øÈëÈÝÆ÷¡£ÔÚÈÝÆ÷ÄÚÖ´ÐÐÏÂÁʹÓà exit ÏÂÁîÍ˳öÈÝÆ÷¡£
ÔõÑù½øÈë Docker ÈÝÆ÷
½øÈë Docker ÈÝÆ÷µÄ°ì·¨ºÜ¼òÆÓ£¬Ö»ÐèÒ»ÌõÏÂÁî¼´¿ÉÍê³É£º
docker exec -it /bin/bash
µÇ¼ºó¸´ÖÆ
Ïêϸ°ì·¨£º
·¿ªÖն˴°¿Ú£ºÔÚ Mac »ò Linux ϵͳÉÏ£¬·¿ªÖն˴°¿Ú¡£ÔÚ Windows ϵͳÉÏ£¬·¿ª Windows PowerShell »òÏÂÁîÌáÐÑ·û¡£
ʶ±ðÈÝÆ÷Ãû³Æ£ºÊ¹ÓÃÒÔÏÂÏÂÁîÉó²éÕýÔÚÔËÐеÄÈÝÆ÷ÁÐ±í£º
docker ps
µÇ¼ºó¸´ÖÆ
Õ⽫Êä³öÈÝÆ÷Ãû³Æ¡¢¾µÏñÃû³Æ¡¢Æô¶¯Ê±¼äµÈÐÅÏ¢¡£
Ö´ÐÐ exec ÏÂÁʹÓà docker exec ÏÂÁî½øÈëÈÝÆ÷¡£ÀýÈ磬Ҫ½øÈëÃûΪ “my-container” µÄÈÝÆ÷£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ
docker exec -it my-container /bin/bash
µÇ¼ºó¸´ÖÆ
-i Ñ¡ÏîÌåÏÖÔÚÈÝÆ÷Öз¿ªÒ»¸ö½»»¥Ê½»á»°¡£
-t Ñ¡ÏîÌåÏÖΪ»á»°·ÖÅÉÒ»¸öαtty¡£
/bin/bash ÏÂÁ/bin/bash ÏÂÁîÔÚÈÝÆ÷ÖÐÆô¶¯Ò»¸ö bash »á»°¡£
ÌáÐÑ·û£ºÀֳɽøÈëÈÝÆ÷ºó£¬Äú½«ÔÚÏÂÁîÌáÐÑ·ûÖп´µ½ root@¡£ÕâÌåÏÖÄúÏÖÔÚÒÑ×÷Ϊ root Óû§µÇ¼µ½ÈÝÆ÷ÖС£
Ö´ÐÐÏÂÁÄúÏÖÔÚ¿ÉÒÔÔÚÈÝÆ÷ÄÚÖ´ÐÐÏÂÁ¾ÍÏñÔÚͨË× Linux ϵͳÖÐÒ»Ñù¡£
Í˳öÈÝÆ÷£ºÒªÍ˳öÈÝÆ÷£¬Ö»Ðè¼üÈë exit ÏÂÁî¼´¿É¡£
ÒÔÉϾÍÊÇdockerÔõÑù½øÈëÈÝÆ÷µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡