ÔõÑùʹÓÃDocker¾ÙÐйÊÕÏÅŲéºÍÎÊÌⶨλ
Ëæ×ÅDockerµÄÆÕ¼°£¬Ô½À´Ô½¶àµÄ¿ª·¢ÕߺÍÔËάְԱ×îÏÈʹÓÃDockerÀ´ÖÎÀíËûÃǵÄÓ¦ÓóÌÐò¡£Docker²»µ«ÌṩÁËÒ»¸öÐéÄ⻯ÇéÐÎÀ´ÔËÐÐÕâЩӦÓóÌÐò£¬»¹Ê¹µÃ°²ÅźÍÖÎÀíÕâЩӦÓóÌÐò±äµÃÔ½·¢ÈÝÒס£È»¶ø£¬Ö»¹Ü Docker ȷʵ¿ÉÒÔʹ×ðÁú¿Ê±ÉúÑıäµÃÔ½·¢ÇáËÉ£¬µ«ÔÚijЩÇéÐÎÏ£¬ËüÒ²¿ÉÄÜ»á´øÀ´Ò»Ð©ÎÊÌâ¡£µ±·ºÆðÎÊÌâʱ£¬ÎÒÃÇÐèҪʹÓà Docker À´¾ÙÐйÊÕÏÅŲéºÍÎÊÌⶨλ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓà Docker À´¾ÙÐйÊÕÏÅŲéºÍÎÊÌⶨ룬²¢ÌṩÏêϸ´úÂëʾÀý¡£
Ò»¡¢Ê¹Óà Docker logs À´Éó²éÈÕÖ¾
DockerÖеÄÈÝÆ÷ÊÇ¿ÉÒÔÊä³öÈÕÖ¾µÄ£¬²¢ÇÒÕâЩÈÕÖ¾ÊÇ¿ÉÒÔͨ¹ý Docker logs ÏÂÁîÀ´Éó²éµÄ¡£ Docker logs ÏÂÁî¿ÉÒÔÓÃÀ´»ñÈ¡ÈÝÆ÷µÄÈÕÖ¾ÐÅÏ¢£¬°üÀ¨ÈÝÆ÷µÄ±ê×¼Êä³öºÍ±ê×¼¹ýʧÊä³ö¡£
ÏÂÃæÊÇÒ»¸öÀý×Ó£º
docker logs my_container
µÇ¼ºó¸´ÖÆ
´ËÏÂÁ´òÓ¡ÃûΪ “my_container” µÄÈÝÆ÷µÄÈÕÖ¾Êä³ö¡£Í¨¹ýÉó²éÈÝÆ÷µÄÈÕÖ¾£¬ÎÒÃÇ¿ÉÒÔÏàʶµ½ÈÝÆ÷ÔÚÔËÐÐʱ±¬·¢ÁËʲô£¬²¢ÕÒ³öµ¼ÖÂÈÝÆ÷ÔËÐÐʧ°ÜµÄÔµ¹ÊÔÓÉ¡£
¶þ¡¢Ê¹Óà Docker exec ÏÂÁîÀ´½øÈëÈÝÆ÷²¢¾ÙÐе÷ÊÔ
ÓÐʱ¼ä£¬Éó²éÈÕÖ¾²¢²»¿É½â¾öÎÊÌ⡣ΪÁ˸üºÃµØɨ³ý¹ÊÕÏ£¬ÎÒÃÇÐèÒªÔÚÈÝÆ÷ÄÚ²¿¾ÙÐе÷ÊÔ¡£Docker ÌṩÁËÒ»¸öÊÊÓóÌÐò£¬¼´ docker exec ÏÂÁÈÃÎÒÃÇ¿ÉÒÔÔÚÔËÐÐÖеÄÈÝÆ÷ÖÐÖ´ÐÐÏÂÁ²¢Éó²éÊä³öЧ¹û¡£
ÏÂÃæÊÇÒ»¸öÀý×Ó£º
docker exec -it my_container bash
µÇ¼ºó¸´ÖÆ
´ËÏÂÁ½øÈëÃûΪ “my_container” µÄÈÝÆ÷²¢Æô¶¯Ò»¸ö Bash Öնˡ£ÔÚÈÝÆ÷ÄÚ²¿£¬ÎÒÃÇ¿ÉÒÔÔËÐÐһЩÏÂÁîÀ´¼ì²éÈÝÆ÷µÄ״̬£¬²¢²éÕÒ¿ÉÄܵĹýʧԵ¹ÊÔÓÉ¡£
Èý¡¢Ê¹Óà Docker ps ÏÂÁîÀ´Éó²éÔËÐÐÖеÄÈÝÆ÷
ÓÐʱ¼ä£¬ÎÒÃÇÐèÒªÉó²éÔËÐÐÖеÄÈÝÆ÷ÁÐ±í£¬ÒÔÈ·¶¨ÄÄЩÈÝÆ÷·ºÆðÁËÎÊÌâ¡£ Docker ÌṩÁËÒ»¸öÊÊÓóÌÐò£¬¼´ docker ps ÏÂÁÈÃÎÒÃÇ¿ÉÒÔÉó²éÕýÔÚÔËÐÐµÄ Docker ÈÝÆ÷ÁÐ±í¡£
ÏÂÃæÊÇÒ»¸öÀý×Ó£º
docker ps
µÇ¼ºó¸´ÖÆ
´ËÏÂÁÁгöËùÓÐÕýÔÚÔËÐÐµÄ Docker ÈÝÆ÷¡£ÎÒÃÇ¿ÉÒÔÉó²éÆä״̬ºÍ¿µ½¡×´Ì¬£¬²¢ÕÒ³öÊÇ·ñ±£´æÒì³£¡£
ËÄ¡¢Ê¹Óà Docker inspect ÏÂÁîÀ´Éó²éÈÝÆ÷ÏêϸÐÅÏ¢
Docker inspect ÏÂÁîÓÃÓÚ»ñÈ¡ÈÝÆ÷µÄÏêϸÐÅÏ¢£¬°üÀ¨ÈÝÆ÷µÄIPµØµã¡¢¶Ë¿ÚÓ³Éä¡¢ÇéÐαäÁ¿ºÍ¹ÒÔصãµÈ¡£
ÏÂÃæÊÇÒ»¸öÀý×Ó£º
docker inspect my_container
µÇ¼ºó¸´ÖÆ
´ËÏÂÁ·µ»ØÓйØÃûΪ “my_container” µÄÈÝÆ÷µÄÏêϸÐÅÏ¢¡£ÎÒÃÇ¿ÉÒÔʹÓÃÕâЩÏêϸÐÅÏ¢À´½øÒ»²½É¨³ýÈκοÉÄܵÄÎÊÌâ¡£
Î塢͎áÒÔÉϹ¤¾ß¾ÙÐÐ×ÛºÏÅŲé
ʹÓà Docker logs¡¢Docker exec¡¢Docker ps ºÍ Docker inspect ÏÂÁîµÄ×éºÏ£¬ÎÒÃÇ¿ÉÒÔ¾ÙÐÐ×ÛºÏÐԵĹÊÕÏÅŲéºÍÎÊÌⶨλ¡£ÏÂÃæÊÇÒ»¸öÀý×Ó£º
docker ps docker logs my_container docker inspect my_container docker exec -it my_container bash
µÇ¼ºó¸´ÖÆ
ʹÓÃÒÔÉÏÏÂÁÎÒÃÇ¿ÉÒÔÕÒ³öÈÝÆ÷ÔËÐÐʧ°ÜµÄÔµ¹ÊÔÓÉ£¬½øÒ»²½ÅŲé¹ÊÕÏ¡£
Áù¡¢×ܽá
Docker ÌṩÁËһЩºÜÊÇÓÐÓõÄÏÂÁîºÍ¹¤¾ß£¬ÓÃÓÚ¾ÙÐйÊÕÏÅŲéºÍÎÊÌⶨλ¡£±¾ÎÄÏÈÈÝÁËһЩÖ÷ÒªµÄ¹¤¾ßºÍÏÂÁ°üÀ¨ Docker logs¡¢Docker exec¡¢Docker ps ºÍ Docker inspect ¡£ÔÚÏÖʵӦÓÃÖУ¬ÎÒÃÇ¿ÉÒÔÍŽáʹÓÃÕâЩ¹¤¾ß£¬ÕÒ³öÈÝÆ÷ÔËÐÐʧ°ÜµÄÔµ¹ÊÔÓÉ£¬²¢¾ÙÐÐÏìÓ¦µÄÐÞ¸´¡£
ÒÔÉϾÍÊÇÔõÑùʹÓÃDocker¾ÙÐйÊÕÏÅŲéºÍÎÊÌⶨλµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡