{"id":243,"date":"2020-10-30T11:54:38","date_gmt":"2020-10-30T03:54:38","guid":{"rendered":"http:\/\/8.154.33.202\/?p=243"},"modified":"2024-09-23T16:34:38","modified_gmt":"2024-09-23T08:34:38","slug":"docker-%e5%b8%b8%e7%94%a8%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"http:\/\/8.154.33.202\/?p=243","title":{"rendered":"docker \u5e38\u7528\u547d\u4ee4"},"content":{"rendered":"\n<p>\u8f7d\u5165\u955c\u50cf\u542f\u52a8\u5bb9\u5668<br>docker run -it image-name:tag<br> \u8f7d\u5165\u955c\u50cf\u542f\u52a8\u5bb9\u5668\uff08\u542f\u7528GPU\uff09<br>docker run -it &#8211;gpus all image-name:tag<br>\u67e5\u770b\u5bb9\u5668\u8fd0\u884c\u60c5\u51b5<br>docker ps -a<br>\u505c\u6b62\u8fd0\u884c\u7684\u5bb9\u5668<br>docker stop containerid<br>\u505c\u6b62\u6240\u6709\u8fd0\u884c\u7684\u5bb9\u5668<br>docker stop $(docker ps -a -q) \u62ec\u53f7\u4e2d\u7684\u547d\u4ee4\u662f\u67e5\u770b\u6240\u6709\u5bb9\u5668ID<br>\u91cd\u542f\u5bb9\u5668<br>docker restart containerid<br>\u8fdb\u5165\u5bb9\u5668<br>docker attach containerid \\ docker exec -it containerid \/bin\/bash<br>\u91cd\u542f\u5e76\u8fdb\u5165\u5bb9\u5668<br>docker start -i containerid<\/p>\n\n\n\n<p>\u7aef\u53e3\u3001\u76ee\u5f55\u6620\u5c04<br>docker run -p \u4e3b\u673a\u7aef\u53e3:\u5bb9\u5668\u7aef\u53e3  image:tag<br>docker run -it -v \u4e3b\u673a\u76ee\u5f55:\u5bb9\u5668\u76ee\u5f55 image:tag \u6ce8\uff1a\u76ee\u5f55\u5fc5\u987b\u662f\u7edd\u5bf9\u8def\u5f84<\/p>\n\n\n\n<p>\u8bbe\u7f6e\u5171\u4eab\u5185\u5b58\u5bb9\u91cf<br>docker run &#8230; &#8211;shm-size 8G<\/p>\n\n\n\n<p>\u5728\u5bb9\u5668\u4e2d\u8fd0\u884c\u7a0b\u5e8f\u62a5nccl\u9519\u8bef\uff0c\u53ef\u4ee5\u5728\u542f\u52a8\u5bb9\u5668\u65f6\u52a0\u4e0a&#8211;ipc=host\u53c2\u6570<\/p>\n\n\n\n<p><br>\u67e5\u770b\u5bb9\u5668\u8fd0\u884c\u60c5\u51b5<br>docker ps -a<br>\u505c\u6b62\u8fd0\u884c\u7684\u5bb9\u5668<br>docker stop containerid<br>\u505c\u6b62\u6240\u6709\u8fd0\u884c\u7684\u5bb9\u5668<br>docker stop $(docker ps -a -q) \u62ec\u53f7\u4e2d\u7684\u547d\u4ee4\u662f\u67e5\u770b\u6240\u6709\u5bb9\u5668ID<br>\u91cd\u542f\u5bb9\u5668<br>docker restart containerid<br>\u8fdb\u5165\u5bb9\u5668<br>docker attach containerid \\ docker exec -it containerid \/bin\/bash<br>\u91cd\u542f\u5e76\u8fdb\u5165\u5bb9\u5668<br>docker start -i containerid<\/p>\n\n\n\n<p><br>\u5220\u9664\u5bb9\u5668<br>docker rm containerid<br>\u5220\u9664\u6240\u6709\u5bb9\u5668<br>docker rm $(docker ps -a -q)<br><br>\u67e5\u770b\u955c\u50cf<br>docker images<br>\u5220\u9664\u955c\u50cf\uff08\u9700\u8981\u5148\u505c\u6b62\u5e76\u5220\u9664\u4f7f\u7528\u8be5\u955c\u50cf\u8fd0\u884c\u7684\u5bb9\u5668\uff09<br>docker rmi imageid \uff08\u52a0\u4e0a -f \u53ef\u4ee5\u5f3a\u5236\u5220\u9664\uff09<\/p>\n\n\n\n<p>\u5c06\u5bb9\u5668\u4fdd\u5b58\u4e3a\u955c\u50cf<br>docker commit  -a  &#8216;\u4fee\u6539\u4f5c\u8005&#8217; -m &#8216;\u63cf\u8ff0&#8217; containerID image-name:new-tag <\/p>\n\n\n\n<p>\u5c06\u955c\u50cf\u6253\u5305\u4e3atar\u6587\u4ef6<br>docker save -o xxx.tar image-name:tag<br>\u4ece\u6253\u5305\u6587\u4ef6\u63d0\u53d6\u955c\u50cf<br>docker load -i xxx.tar<br>\u63d0\u53d6\u4e4b\u540e\u955c\u50cf\u4f1a\u4fdd\u5b58\u5230\u672c\u5730\uff0c\u5c31\u53ef\u4ee5\u8fd0\u884c\u8be5\u955c\u50cf\u4e86<\/p>\n\n\n\n<p>\u5c06\u5bb9\u5668\u6253\u5305\u4e3atar\u6587\u4ef6<br>docker export -o xxx.tar container-name<br>\u5c06export\u6253\u5305\u7684\u6587\u4ef6\u63d0\u53d6\u51fa\u955c\u50cf<br>docker import xxx.tar image-name:tag \u6ce8\uff1a\u8fd9\u91ccimage-name:tag\u662f\u81ea\u5df1\u53d6\u7684<br><br>docker save\u548cexport\u7684\u533a\u522b<br>docker save\u4f1a\u4fdd\u5b58\u955c\u50cf\u7684\u5386\u53f2\u8bb0\u5f55\uff0c\u800cexport\u4e0d\u4f1a\u4fdd\u5b58\u3002export\u4ec5\u4fdd\u5b58\u5bb9\u5668\u5f53\u524d\u7684\u72b6\u6001<\/p>\n\n\n\n<p>\u538b\u7f29\u955c\u50cf\u5927\u5c0f<br>pip\u00a0install\u00a0docker-squash<br>docker-squash\u00a0image:old\u00a0-t\u00a0image:new<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f7d\u5165\u955c\u50cf\u542f\u52a8\u5bb9\u5668docker run -it image-name:tag \u8f7d\u5165\u955c\u50cf\u542f\u52a8\u5bb9\u5668\uff08\u542f\u7528GPU\uff09do &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/8.154.33.202\/?p=243\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cdocker \u5e38\u7528\u547d\u4ee4\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-243","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/posts\/243"}],"collection":[{"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/8.154.33.202\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=243"}],"version-history":[{"count":9,"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/posts\/243\/revisions"}],"predecessor-version":[{"id":520,"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/posts\/243\/revisions\/520"}],"wp:attachment":[{"href":"http:\/\/8.154.33.202\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/8.154.33.202\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/8.154.33.202\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}