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

dockerÈÝÆ÷ÄÚ²¿Ôõô±à¼­

±à¼­ docker ÈÝÆ÷ÄÚÎļþµÄÒªÁ죺ÕýÔÚÔËÐеÄÈÝÆ÷£ºdocker exec£ºdocker exec -it /bin/bashdocker-compose exec£ºdocker-compose exec /bin/bashÖ±½Ó±à¼­£ºcat /path/to/file | docker exec -i tee /path/to/fileÒÑ×èÖ¹µÄÈÝÆ÷£ºdocker cp£º

Docker ÈÝÆ÷Äڵı༭ҪÁì

±à¼­ Docker ÈÝÆ÷ÄÚµÄÎļþÓжàÖÖÒªÁ죬Ïêϸȡ¾öÓÚÈÝÆ÷µÄÔËÐÐ״̬¡£

ÕýÔÚÔËÐеÄÈÝÆ÷

ʹÓà Docker Exec ÏÂÁ

docker exec -it <container-id> /bin/bash</container-id>

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ʹÓà Docker-compose exec ÏÂÁ

docker-compose exec <service-name> /bin/bash</service-name>

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ʹÓÃÖ±½Ó±à¼­£º

cat /path/to/file | docker exec -i <container-id> tee /path/to/file</container-id>

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÒÑ×èÖ¹µÄÈÝÆ÷

ʹÓà Docker cp ÏÂÁ

docker cp <source-path><container-id>:/destination-path</container-id></source-path>

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ʹÓà Docker commit ÏÂÁ

docker commit <container-id><new-image-name></new-image-name></container-id>

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ʹÓà Dockerfile ºÍ Docker Build£º

½¨Éè Dockerfile£¬½«ËùÐèÎļþ¸´ÖƵ½ÈÝÆ÷ÖУ¬È»ºó¹¹½¨ÐÂÓ³Ïñ¡£

Ïêϸ˵Ã÷

ʹÓà Docker Exec

ÕâÊǽøÈëÕýÔÚÔËÐеÄÈÝÆ÷²¢Ê¹ÓÃÆäÏÂÁîÐнçÃæ±à¼­ÎļþµÄ×î¿ì½ÝÒªÁì¡£Ö»ÐèʹÓà exec ÏÂÁÈçÏÂËùʾ£º

docker exec -it <container-id> /bin/bash</container-id>

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÊÇÈÝÆ÷µÄ ID¡£

-it ÌåÏÖ½»»¥Ê½Öնˡ£

ʹÓà Docker-compose Exec

ÈôÊÇÄãʹÓà Docker Compose ÖÎÀíÈÝÆ÷£¬¿ÉÒÔʹÓà docker-compose exec ÏÂÁî¡£¸ÃÏÂÁîÀàËÆÓÚ docker exec£¬µ«ËüÕë¶ÔµÄÊÇʹÓà Docker Compose ½ç˵µÄÈÝÆ÷¡£

docker-compose exec <service-name> /bin/bash</service-name>

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÊÇ Docker Compose ÎļþÖнç˵µÄЧÀÍÃû³Æ¡£

ʹÓÃÖ±½Ó±à¼­

´ËÒªÁìÔÊÐíÄ㽫ÎļþÖ±½ÓÊܵÀµ½ÈÝÆ÷ÖС£Õâ¹ØÓÚÐèÒªÔÚÈÝÆ÷ÄÚ½¨Éè»òÐÞ¸ÄСÎļþºÜÊÇÓÐÓá£

cat /path/to/file | docker exec -i <container-id> tee /path/to/file</container-id>

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ʹÓà Docker Cp

¹ØÓÚÒÑ×èÖ¹µÄÈÝÆ÷£¬¿ÉÒÔʹÓà docker cp ÏÂÁÎļþ´ÓÍâµØϵͳ¸´ÖƵ½ÈÝÆ÷ÖС£

docker cp <source-path><container-id>:/destination-path</container-id></source-path>

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÊÇÍâµØÎļþ·¾¶¡£

ÊÇÈÝÆ÷µÄ ID¡£

:/destination-path ÊÇÈÝÆ÷ÄÚµÄÄ¿µÄ·¾¶¡£

ʹÓà Docker Commit

ÈôÊÇÄãÐèÒªÓÀÊÀÉúÑĸü¸Ä£¬¿ÉÒÔʹÓà docker commit ÏÂÁî¡£´ËÏÂÁÉèÒ»¸öÐÂÓ³Ïñ£¬ÆäÖаüÀ¨Ð޸ĺóµÄÎļþ¡£

docker commit <container-id><new-image-name></new-image-name></container-id>

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÊÇÈÝÆ÷µÄ ID¡£

ÊÇÐÂÓ³ÏñµÄÃû³ÆºÍ±ê¼Ç¡£

ʹÓà Dockerfile ºÍ Docker Build

ÈôÊÇÄãÐèÒªÔÚÈÝÆ÷Æô¶¯Ê±ÐÞ¸ÄÎļþ£¬¿ÉÒÔʹÓà Dockerfile ºÍ docker build ÏÂÁî¡£ÔÚ Dockerfile Öн¨ÉèÒÔÏÂÖ¸Á

COPY <source-path> /path/to/destination</source-path>

µÇ¼ºó¸´ÖÆ

È»ºó¹¹½¨ÐÂÓ³Ïñ£º

docker build .

µÇ¼ºó¸´ÖÆ

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ