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

dockerÔËÐÐÈÝÆ÷ÔõôÓÃ

ÒªÔËÐÐ docker ÈÝÆ÷£¬ÐèÒÀ´ÎÖ´ÐУºÀ­È¡¾µÏñ (docker pull )½¨ÉèÈÝÆ÷ (docker run -it –rm –name )½»»¥²Ù×÷ÈÝÆ÷ (docker exec -it /bin/bash)¶Ë¿ÚÓ³Éä (docker run -it –rm –name my-nginx -p 8080:80 nginx)ÉèÖÃÇéÐαäÁ¿ (docker run -it –rm –name

ÔõÑùÔËÐÐ Docker ÈÝÆ÷

ÔËÐÐ Docker ÈÝÆ÷Éæ¼°ÒÔÏ°취£º

1. À­È¡¾µÏñ

Ê×ÏÈ£¬ÐèÒªÀ­È¡ËùÐè¾µÏñ¡£¾µÏñÊÇ°üÀ¨Ó¦ÓóÌÐò¡¢¿âºÍÒÀÀµÏîµÄ¿ÉÖ´ÐÐÎļþ¡£Ê¹ÓÃÒÔÏÂÏÂÁîÀ­È¡¾µÏñ£º

docker pull 

µÇ¼ºó¸´ÖÆ

ÀýÈ磬ҪÀ­È¡ Nginx ¾µÏñ£º

docker pull nginx

µÇ¼ºó¸´ÖÆ

2. ½¨ÉèÈÝÆ÷

À­È¡¾µÏñºó£¬¿ÉÒÔʹÓà docker run ÏÂÁÉèÈÝÆ÷¡£¸ÃÏÂÁîÔÊÐíÖ¸¶¨ÈÝÆ÷µÄÔËÐÐÉèÖã¬ÀýÈç¶Ë¿ÚÓ³ÉäºÍÇéÐαäÁ¿¡£ÒÔÏÂÊÇÒ»¸ö»ù±¾Ê¾Àý£º

docker run -it --rm --name  

µÇ¼ºó¸´ÖÆ

ÀýÈ磬Ҫ½¨ÉèÒ»¸öÃûΪ “my-nginx” µÄÈÝÆ÷£º

docker run -it --rm --name my-nginx nginx

µÇ¼ºó¸´ÖÆ

3. ½»»¥²Ù×÷

ÈÝÆ÷½¨Éèºó£¬¿ÉÒÔʹÓý»»¥Ê½Ä£Ê½½øÈëÈÝÆ÷¡£ÕâÔÊÐíÔÚÈÝÆ÷ÄÚÖ´ÐÐÏÂÁîºÍÉó²éÊä³ö¡£ÒÔÏÂÊǽøÈëÈÝÆ÷µÄÏÂÁ

docker exec -it  /bin/bash

µÇ¼ºó¸´ÖÆ

4. ¶Ë¿ÚÓ³Éä

ÈôÊÇÈÝÆ÷ÐèҪ̻¶¶Ë¿ÚÒÔÓëÍⲿÌìÏÂͨѶ£¬ÔòÐèÒª¾ÙÐж˿ÚÓ³Éä¡£Õâ¿ÉÒÔʹÓà -p ±ê¼ÇÍê³É£¬¸Ã±ê¼ÇÖ¸¶¨Ö÷»ú¶Ë¿ÚºÍÈÝÆ÷¶Ë¿Ú¡£ÒÔÏÂʾÀý½«ÈÝÆ÷ÖÐµÄ 80 ¶Ë¿ÚÓ³Éäµ½Ö÷»úÉ쵀 8080 ¶Ë¿Ú£º

docker run -it --rm --name my-nginx -p 8080:80 nginx

µÇ¼ºó¸´ÖÆ

5. ÇéÐαäÁ¿

¿ÉÒÔÔÚ½¨ÉèÈÝÆ÷ʱÉèÖÃÇéÐαäÁ¿£¬ÒÔ±ãÈÝÆ÷ÄÚµÄÓ¦ÓóÌÐò¿ÉÒÔ»á¼ûËüÃÇ¡£Ê¹Óà -e ±ê¼ÇÖ¸¶¨ÇéÐαäÁ¿£¬ÈçÏÂËùʾ£º

docker run -it --rm --name my-nginx -e MY_ENV_VAR=value nginx

µÇ¼ºó¸´ÖÆ

6. ×èÖ¹ºÍɾ³ýÈÝÆ÷

µ±ÈÝÆ÷²»ÔÙÐèҪʱ£¬¿ÉÒÔʹÓà docker stop ÏÂÁî×èÖ¹Ëü£¬È»ºóʹÓà docker rm ÏÂÁîɾ³ýËü¡£ÒÔÏÂʾÀýÏÔʾÔõÑù×èÖ¹ºÍɾ³ý “my-nginx” ÈÝÆ÷£º

docker stop my-nginx
docker rm my-nginx

µÇ¼ºó¸´ÖÆ

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ