dockerÔõô½øÈëÈÝÆ÷Ŀ¼
½øÈë docker ÈÝÆ÷Ŀ¼µÄÒªÁ죺ʹÓà docker exec ÏÂÁîʹÓà docker attach ÏÂÁîʹÓà docker run ÏÂÁîʹÓà docker cp ÏÂÁî
ÔõÑù½øÈë Docker ÈÝÆ÷Ŀ¼
µ±ÄãÐèÒª»á¼û Docker ÈÝÆ÷ÄÚµÄĿ¼ʱ£¬¿ÉÒÔʹÓÃÒÔÏÂÒªÁ죺
1. ʹÓà Docker exec ÏÂÁî
ÕâÊǽøÈëÈÝÆ÷µÄ×î³£¼ûÒªÁ죺
docker exec -it /bin/bash
µÇ¼ºó¸´ÖÆ
ÀýÈ磬Ҫ½øÈëÃûΪ “my-container” µÄÈÝÆ÷£¬ÇëÔËÐУº
docker exec -it my-container /bin/bash
µÇ¼ºó¸´ÖÆ
2. ʹÓà Docker attach ÏÂÁî
Õâ»á½«Ä㸽¼Óµ½ÈÝÆ÷µÄ±ê×¼ÊäÈë¡¢Êä³öºÍ¹ýʧÁ÷£º
docker attach
µÇ¼ºó¸´ÖÆ
ÀýÈ磬Ҫ¸½¼Óµ½ “my-container” ÈÝÆ÷£¬ÇëÔËÐУº
docker attach my-container
µÇ¼ºó¸´ÖÆ
3. ʹÓà Docker run ÏÂÁî
Õ⽫ÔËÐÐÒ»¸öеÄÈÝÆ÷£¬²¢ÔÊÐíÄãÖ¸¶¨Òª¹ÒÔصÄÖ÷»úĿ¼£º
docker run --rm -ti -v :/container/directory /bin/bash
µÇ¼ºó¸´ÖÆ
ÀýÈ磬Ҫ½«ÍâµØĿ¼ “/my/local/directory” ¹ÒÔص½ÈÝÆ÷ÄÚµÄ “/container/directory”£¬ÇëÔËÐУº
docker run --rm -ti -v /my/local/directory:/container/directory my-image /bin/bash
µÇ¼ºó¸´ÖÆ
4. ʹÓà Docker cp ÏÂÁî
ÕâÔÊÐíÄ㽫Îļþ»òĿ¼´ÓÈÝÆ÷¸´ÖƵ½Ö÷»ú»ò´ÓÖ÷»ú¸´ÖƵ½ÈÝÆ÷£º
docker cp :
µÇ¼ºó¸´ÖÆ
ÀýÈ磬Ҫ½«ÈÝÆ÷ÖÐµÄ “/container/file.txt” Îļþ¸´ÖƵ½Ö÷»úÉ쵀 “/my/local/file.txt”£¬ÇëÔËÐУº
docker cp my-container:/container/file.txt /my/local/file.txt
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇdockerÔõô½øÈëÈÝÆ÷Ŀ¼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡