ÔõÑùʹÓÃDocker¾ÙÐÐÈÝÆ÷µÄÅúÁ¿²Ù×÷ºÍÖÎÀí
ÔõÑùʹÓÃDocker¾ÙÐÐÈÝÆ÷µÄÅúÁ¿²Ù×÷ºÍÖÎÀí
Ëæ×ÅÔÆÅÌËãºÍÈÝÆ÷»¯ÊÖÒյĿìËÙÉú³¤£¬DockerÒѳÉΪ×îÊܽӴýºÍÆÕ±éÓ¦ÓõÄÈÝÆ÷»¯Æ½Ì¨Ö®Ò»¡£ÔÚÏÖʵӦÓÃÖУ¬ÎÒÃǾ³£ÐèÒª¶Ô¶à¸öÈÝÆ÷¾ÙÐÐÅúÁ¿²Ù×÷ºÍÖÎÀí¡£±¾ÎĽ«ÏÈÈÝһЩʹÓÃDocker¾ÙÐÐÈÝÆ÷ÅúÁ¿²Ù×÷ºÍÖÎÀíµÄÒªÁ죬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£
Ò»¡¢DockerÈÝÆ÷ÅúÁ¿²Ù×÷
Éó²éÈÝÆ÷Áбí
ʹÓÃdockerÏÂÁî¿ÉÒÔÉó²éÄ¿½ñÕýÔÚÔËÐеÄÈÝÆ÷ÁÐ±í¡£Ïêϸ´úÂëÈçÏ£º
docker ps
µÇ¼ºó¸´ÖÆ
ÕâÐÐÏÂÁÏÔʾĿ½ñÕýÔÚÔËÐеÄÈÝÆ÷µÄÏêϸÐÅÏ¢£¬°üÀ¨ÈÝÆ÷ID¡¢ÈÝÆ÷Ãû¡¢ËùÓþµÏñ¡¢Æô¶¯Ê±¼äµÈ¡£
Æô¶¯ÈÝÆ÷
ʹÓÃdockerÏÂÁî¿ÉÒÔÆô¶¯Ö¸¶¨µÄÈÝÆ÷¡£Ïêϸ´úÂëÈçÏ£º
docker start <ÈÝÆ÷ID>
µÇ¼ºó¸´ÖÆ
ÕâÐÐÏÂÁÆô¶¯Ö¸¶¨IDµÄÈÝÆ÷¡£
×èÖ¹ÈÝÆ÷
ʹÓÃdockerÏÂÁî¿ÉÒÔ×èÖ¹Ö¸¶¨µÄÈÝÆ÷¡£Ïêϸ´úÂëÈçÏ£º
docker stop <ÈÝÆ÷ID>
µÇ¼ºó¸´ÖÆ
ÕâÐÐÏÂÁ×èÖ¹Ö¸¶¨IDµÄÈÝÆ÷¡£
ÖØÆôÈÝÆ÷
ʹÓÃdockerÏÂÁî¿ÉÒÔÖØÆôÖ¸¶¨µÄÈÝÆ÷¡£Ïêϸ´úÂëÈçÏ£º
docker restart <ÈÝÆ÷ID>
µÇ¼ºó¸´ÖÆ
ÕâÐÐÏÂÁÖØÆôÖ¸¶¨IDµÄÈÝÆ÷¡£
ɾ³ýÈÝÆ÷
ʹÓÃdockerÏÂÁî¿ÉÒÔɾ³ýÖ¸¶¨µÄÈÝÆ÷¡£Ïêϸ´úÂëÈçÏ£º
docker rm <ÈÝÆ÷ID>
µÇ¼ºó¸´ÖÆ
ÕâÐÐÏÂÁɾ³ýÖ¸¶¨IDµÄÈÝÆ÷£¬ÈôÊÇÈÝÆ÷ÕýÔÚÔËÐУ¬ÐèÒªÏÈ×èÖ¹ÈÝÆ÷²Å»ªÉ¾³ý¡£
¶þ¡¢DockerÈÝÆ÷ÅúÁ¿ÖÎÀí
ÅúÁ¿Æô¶¯ÈÝÆ÷
ÈôÊÇÎÒÃÇÓÐÒ»¸ö°üÀ¨¶à¸öÈÝÆ÷µÄÏîÄ¿£¬¿ÉÒÔʹÓÃdocker-compose¹¤¾ßÀ´ÅúÁ¿Æô¶¯ÈÝÆ÷¡£Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚÏîÄ¿¸ùĿ¼Ï½¨ÉèÒ»¸ödocker-compose.ymlÎļþ£¬²¢ÔÚ¸ÃÎļþÖнç˵ÈÝÆ÷µÄÉèÖá£ÒÔÏÂÊÇÒ»¸öʾÀý£º
version: '3' services: web: image: nginx:latest ports: - "80:80" database: image: mysql:latest environment: - MYSQL_ROOT_PASSWORD=123456
µÇ¼ºó¸´ÖÆ
ÔÚÏîÄ¿¸ùĿ¼ÏÂÖ´ÐÐÒÔÏÂÏÂÁî¼´¿ÉÆô¶¯ËùÓÐÈÝÆ÷£º
docker-compose up -d
µÇ¼ºó¸´ÖÆ
ÅúÁ¿×èÖ¹ÈÝÆ÷
ʹÓÃdocker-compose¹¤¾ß¿ÉÒÔÅúÁ¿×èÖ¹ËùÓÐÕýÔÚÔËÐеÄÈÝÆ÷¡£ÔÚÏîÄ¿¸ùĿ¼ÏÂÖ´ÐÐÒÔÏÂÏÂÁî¼´¿É×èÖ¹ËùÓÐÈÝÆ÷£º
docker-compose down
µÇ¼ºó¸´ÖÆ
ÅúÁ¿É¾³ýÈÝÆ÷
ʹÓÃdocker-compose¹¤¾ß¿ÉÒÔÅúÁ¿É¾³ýËùÓÐÈÝÆ÷¡£ÔÚÏîÄ¿¸ùĿ¼ÏÂÖ´ÐÐÒÔÏÂÏÂÁî¼´¿Éɾ³ýËùÓÐÈÝÆ÷£¬Í¬Ê±»áɾ³ýÈÝÆ÷µÄÏà¹ØÉèÖãº
docker-compose rm
µÇ¼ºó¸´ÖÆ
Èý¡¢×ܽá
±¾ÎÄÏÈÈÝÁËʹÓÃDocker¾ÙÐÐÈÝÆ÷µÄÅúÁ¿²Ù×÷ºÍÖÎÀíµÄÒªÁ죬²¢ÌṩÁËÏêϸµÄ´úÂëʾÀý¡£Í¨¹ýʹÓÃdockerÏÂÁîºÍdocker-compose¹¤¾ß£¬ÎÒÃÇ¿ÉÒÔÀû±ãµØ¶Ô¶à¸öÈÝÆ÷¾ÙÐÐÅúÁ¿²Ù×÷ºÍÖÎÀí£¬Ìá¸ßÁËÈÝÆ÷»¯ÇéÐεÄЧÂÊ¡£ÔÚÏÖʵӦÓÃÖУ¬¿ÉÒÔƾ֤ÏîÄ¿µÄÐèÇóÎÞаÔËÓÃÕâЩҪÁ죬ʵÏÖ¸üÀû±ã¡¢¸ßЧµÄÈÝÆ÷ÖÎÀí¡£
ÒÔÉϾÍÊÇÔõÑùʹÓÃDocker¾ÙÐÐÈÝÆ÷µÄÅúÁ¿²Ù×÷ºÍÖÎÀíµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡