×ðÁú¿­Ê±¹ÙÍøµÇ¼

dockerÔõôÉó²éÈÕÖ¾

Éó²é docker ÈÕÖ¾µÄÒªÁì°üÀ¨£ºÊ¹Óà docker logs ÏÂÁÀýÈ磺docker logs container_nameʹÓà docker exec ÏÂÁîÔËÐÐ /bin/sh ²¢Éó²éÈÕÖ¾Îļþ£¬ÀýÈ磺docker exec -it container_name /bin/sh ; cat /var/log/container_name.logʹÓà docker compose µÄ docker-compose logs ÏÂÁÀýÈ磺docker-compose -f docker-com

ÔõÑùÉó²é Docker ÈÕÖ¾

Docker ÈÕÖ¾ÊÇÕï¶ÏÏ¢Õù¾öÈÝÆ÷ÎÊÌâµÄÃû¹ó×ÊÔ´ ¡£ÒÔÏÂÊÇÉó²é Docker ÈÕÖ¾µÄÈýÖÖÒªÁ죺

1. ʹÓà docker logs ÏÂÁî

docker logs ÏÂÁîÊÇ×î¼òÆÓµÄÉó²éÈÕÖ¾µÄÒªÁì ¡£Ëü½«Êä³öÖ¸¶¨ÈÝÆ÷µÄ±ê×¼Êä³öºÍ¹ýʧÁ÷ ¡£

docker logs CONTAINER_NAME

µÇ¼ºó¸´ÖÆ

ÀýÈ磬ҪÉó²éÃûΪ “my-container” µÄÈÝÆ÷µÄÈÕÖ¾£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

docker logs my-container

µÇ¼ºó¸´ÖÆ

2. ʹÓà docker exec ÏÂÁî

docker exec ÏÂÁîÔÊÐíÄúÔÚÈÝÆ÷ÖÐÔËÐÐÏÂÁî ¡£Äú¿ÉÒÔʹÓôËÏÂÁîÀ´Éó²éÈÕÖ¾Îļþ ¡£

docker exec -it CONTAINER_NAME /bin/sh

µÇ¼ºó¸´ÖÆ

È»ºó£¬Äú¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÉó²éÈÕÖ¾Îļþ£º

cat /var/log/CONTAINER_NAME.log

µÇ¼ºó¸´ÖÆ

ÀýÈ磬ҪÉó²éÃûΪ “my-container” µÄÈÝÆ÷µÄÈÕÖ¾Îļþ£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

docker exec -it my-container /bin/sh
cat /var/log/my-container.log

µÇ¼ºó¸´ÖÆ

3. ʹÓà Docker Compose

ÈôÊÇÄúʹÓà Docker Compose ÖÎÀíÄúµÄÓ¦ÓóÌÐò£¬Ôò¿ÉÒÔʹÓà docker-compose logs ÏÂÁîÉó²éÈÕÖ¾ ¡£´ËÏÂÁÊä³öËùÓÐЧÀ͵ÄÈÕÖ¾ ¡£

docker-compose logs

µÇ¼ºó¸´ÖÆ

ÀýÈ磬ҪÉó²éÃûΪ “my-app” µÄ Docker Compose Ó¦ÓóÌÐòµÄÈÕÖ¾£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

docker-compose -f docker-compose.yml logs

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇdockerÔõôÉó²éÈÕÖ¾µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Á¢³ ¡£¬Çë¶ÁÕß½ö×ö²Î¿¼ ¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý ¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ