{"id":1666,"date":"2023-08-27T10:35:00","date_gmt":"2023-08-27T02:35:00","guid":{"rendered":"https:\/\/systw.net\/note\/?p=1666"},"modified":"2024-11-07T10:24:45","modified_gmt":"2024-11-07T02:24:45","slug":"docker","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/1666","title":{"rendered":"Docker"},"content":{"rendered":"\n<p>Docker\u662f\u8f15\u91cf\u7d1a\u7684\u865b\u64ec\u5316\u89e3\u6c7a\u65b9\u6848\uff0c\u4f7f\u7528container\u7684\u6280\u8853\uff0c\u985e\u4f3c\u865b\u64ec\u6a5f\u6280\u8853\uff0c\u4f46\u4e0d\u7528\u50cf\u865b\u64ec\u6a5f\u5728\u591a\u6e96\u5099Guest OS<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u67b6\u69cb\u6bd4\u8f03 <\/h3>\n\n\n\n<p>Virtural Machine \u67b6\u69cb\uff1aHost OS | Hypervisor | Guest OS | bins\/libs | APP1<br>Docker \u67b6\u69cb\uff1aHost OS | Docker Enginer | bins\/libs | APP1<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u512a\u9ede\uff1a<\/h3>\n\n\n\n<p>\u4e00\u6b21\u5efa\u7acb\u6216\u8a2d\u5b9a\uff0c\u53ef\u4ee5\u5728\u4efb\u610f\u5730\u65b9\u6b63\u5e38\u57f7\u884c<br>\u6838\u5fc3\u5c64\u7d1a\u7684\u865b\u64ec\u5316\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u984d\u5916\u7684\u865b\u64ec\u5316\u652f\u63f4\uff0c\u56e0\u6b64\u53ef\u4ee5\u5be6\u4f5c\u66f4\u9ad8\u7684\u6548\u80fd\u548c\u6548\u7387<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u904b\u4f5cDocker\u7684\u4e09\u500b\u91cd\u8981\u5143\u4ef6<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6620\u50cf\u6a94\uff08Image\uff09<\/li>\n\n\n\n<li>\u5bb9\u5668\uff08Container\uff09<\/li>\n\n\n\n<li>\u5009\u5eab\uff08Repository\uff09<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Docker Image&nbsp;<\/h4>\n\n\n\n<p>\u5c31\u662f\u4e00\u500b\u552f\u8b80\u7684\u6a21\u677f\uff0c\u88e1\u9762\u50c5\u5b89\u88dd\u4f7f\u7528\u8005\u9700\u8981\u7684\u61c9\u7528\u7a0b\u5f0f<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Docker Container<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u3000\u5f9e\u6620\u50cf\u6a94\u5efa\u7acb\u7684\u57f7\u884c\u5be6\u4f8b\uff0cDocker \u5229\u7528Container\u4f86\u57f7\u884c\u61c9\u7528<\/li>\n\n\n\n<li>\u3000Container\u53ef\u4ee5\u88ab\u555f\u52d5\u3001\u958b\u59cb\u3001\u505c\u6b62\u3001\u522a\u9664\u3000<\/li>\n\n\n\n<li>\u3000\u6bcf\u500bContainer\u90fd\u662f\u76f8\u4e92\u9694\u96e2\u7684\u74b0\u5883<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Docker Repository<\/h4>\n\n\n\n<p>\u96c6\u4e2d\u5b58\u653e\u6620\u50cf\u6a94\u7684\u5834\u6240\uff0c\u6982\u5ff5\u8ddf Git \u985e\u4f3c\uff0c\u5206\u70ba<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u3000\u3000Public:Docker Hub\uff08\u6700\u5927\u7684\u516c\u958b\u5009\u5eab\uff09\uff0cDocker Pool\uff08\u5927\u9678\u7684\u516c\u958b\u5009\u5eab\uff09&nbsp;<\/li>\n\n\n\n<li>\u3000\u3000Private:\u4f7f\u7528\u8005\u4e5f\u53ef\u4ee5\u5728\u672c\u5730\u7db2\u8def\u5167\u5efa\u7acb\u4e00\u500b\u79c1\u6709\u5009\u5eab<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b89\u88dd\u8207\u555f\u52d5<\/h3>\n\n\n\n<p>\u4ee5\u4e0b\u4ee5centos\u70ba\u4f8b <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install docker&nbsp;\nsudo systemctl start docker<\/code><\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Docker image<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5217\u51fa\u672c\u6a5f\u4e0a\u7684docker image<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo docker images\nREPOSITORY &nbsp; &nbsp; &nbsp; TAG&nbsp; &nbsp; &nbsp; IMAGE ID&nbsp; &nbsp; &nbsp; CREATED&nbsp; &nbsp; &nbsp; VIRTUAL SIZE\nubuntu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 12.04&nbsp; &nbsp; 74fe38d11401&nbsp; 4 weeks ago&nbsp; 209.6 MB\nubuntu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; precise&nbsp; 74fe38d11401&nbsp; 4 weeks ago&nbsp; 209.6 MB\nubuntu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 14.04&nbsp; &nbsp; 99ec81b80c55&nbsp; 4 weeks ago&nbsp; 266 MB\nubuntu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; latest &nbsp; 99ec81b80c55&nbsp; 4 weeks ago&nbsp; 266 MB\nubuntu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trusty &nbsp; 99ec81b80c55&nbsp; 4 weeks ago&nbsp; 266 MB<\/code><\/pre>\n\n\n\n<p>\u8aaa\u660e<\/p>\n\n\n\n<p>REPOSITORY: \u4f86\u81ea\u65bc\u54ea\u500b\u5009\u5eab\uff0c\u6bd4\u5982 ubuntu<\/p>\n\n\n\n<p>TAG : \u6620\u50cf\u6a94\u7684\u6a19\u8a18\uff0c\u7528\u4f86\u6a19\u8a18\u4f86\u81ea\u540c\u4e00\u500b\u5009\u5eab\u7684\u4e0d\u540c\u6620\u50cf\u6a94\uff0c\u5982\u679c\u6c92\u6709\u6307\u5b9a TAG\uff0c\u9810\u8a2d\u4f7f\u7528 latest<\/p>\n\n\n\n<p>IMAGE ID:image\u7684\u552f\u4e00ID \u865f\uff0c\u5177\u6709\u76f8\u540c\u7684\u6620\u50cf\u6a94 ID\uff0c\u8aaa\u660e\u5b83\u5011\u5be6\u969b\u4e0a\u662f\u540c\u4e00\u6620\u50cf\u6a94\uff0c\u4f8b\u5982 ubuntu:14.04 \u548c ubuntu:trusty<\/p>\n\n\n\n<p>CREATED: \u5efa\u7acb\u6642\u9593<\/p>\n\n\n\n<p>VIRTUAL SIZE:\u6620\u50cf\u6a94\u5927\u5c0f<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f9edocker hub\u53d6\u5f97\u548c\u4e0a\u50b3<\/h3>\n\n\n\n<p>\u5728docker hub\u5c0b\u627e\u9700\u6c42\u7684image<\/p>\n\n\n\n<p><code>$sudo docker search ubuntu<\/code><\/p>\n\n\n\n<p>\u5f9eDocker Hub \u53d6\u5f97\u5df2\u6709\u6620\u50cf\u6a94<\/p>\n\n\n\n<p><code>$sudo docker pull ubuntu:12.04<\/code><\/p>\n\n\n\n<p><code>$sudo docker pull registry.hub.docker.com\/ubuntu:12.04<\/code><\/p>\n\n\n\n<p>\u628aimage\u4e0a\u50b3\u5230Docker Hub&nbsp;<\/p>\n\n\n\n<p><code>$sudo docker push ubuntu:12.04<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f9e\u672c\u5730\u53d6\u5f97\u548c\u8f09\u5165<\/h3>\n\n\n\n<p>\u5132\u5b58\u672c\u5730\u7aefimage<\/p>\n\n\n\n<p><code>$sudo docker save -o ubuntu_14.04.tar ubuntu:14.04<\/code><\/p>\n\n\n\n<p>\u8f09\u5165\u672c\u5730\u7aefimage<\/p>\n\n\n\n<p><code>$sudo docker load --input ubuntu_14.04.tar<\/code><\/p>\n\n\n\n<p><code>$sudo docker load &lt; ubuntu_14.04.tar<\/code><\/p>\n\n\n\n<p>ps:<\/p>\n\n\n\n<p>\u5f9e\u672c\u6a5f\u532f\u5165\u4e00\u500b\u6620\u50cf\u6a94<\/p>\n\n\n\n<p><code>$sudo cat ubuntu-14.04-x86_64-minimal.tar.gz&nbsp; |docker import - ubuntu:14.04<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u5efa\u7acb\u81ea\u5df1\u7684Docker image<\/h3>\n\n\n\n<p>\u5229\u7528 Dockerfile \u5efa\u7acb\u6620\u50cf\u6a94<\/p>\n\n\n\n<p>\u4fee\u6539\u5df2\u6709\u6620\u50cf\u6a94<\/p>\n\n\n\n<p><code>docker commit&nbsp; [ paramater ] &lt; container id&gt; &lt; image name&gt;<\/code><\/p>\n\n\n\n<p>\u8209\u4f8b\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo docker run -t -i training\/sinatra \/bin\/bash\nroot@0b2616b0e5a8:\/#\nroot@0b2616b0e5a8:\/# gem install json\u3000\u3000#\u5728\u5bb9\u5668\u4e2d\u52a0\u5165 json \u7684 gem \u5957\u4ef6\u3002\n\n$ sudo docker commit -m \"Added json gem\" -a \"Docker Newbee\" 0b2616b0e5a8 ouruser\/sinatra:v2\n4f177bd27a9ff0f6dc2a830403925b5360bfe0b93d476f7fc3231110e7f71b1c\n\n$ sudo docker images\nREPOSITORY&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TAG &nbsp; &nbsp; IMAGE ID &nbsp; &nbsp; &nbsp; CREATED &nbsp; &nbsp; &nbsp; VIRTUAL SIZE\ntraining\/sinatra&nbsp; &nbsp; latest&nbsp; 5bc342fa0b91 &nbsp; 10 hours ago&nbsp; 446.7 MB\nouruser\/sinatra &nbsp; &nbsp; v2&nbsp; &nbsp; &nbsp; 3c59e02ddd1a &nbsp; 10 hours ago&nbsp; 446.7 MB\nouruser\/sinatra &nbsp; &nbsp; latest&nbsp; 5db5f8471261 &nbsp; 10 hours ago&nbsp; 446.7 MB<\/code><\/pre>\n\n\n\n<p>ps: -m \u6307\u5b9a\u63d0\u4ea4\u7684\u8aaa\u660e\u4fe1\u606f<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u522a\u9664\u672c\u5730\u7aefimage<\/h3>\n\n\n\n<p><code>sudo docker rmi training\/sinatra<\/code><\/p>\n\n\n\n<p>ps:<\/p>\n\n\n\n<p>\u5728\u522a\u9664docker image\u4e4b\u524d\u8981\u5148\u7528 docker rm \u522a\u6389\u4f9d\u8cf4\u65bc\u9019\u500b\u6620\u50cf\u6a94\u7684\u6240\u6709container&nbsp;<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Docker container<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u57fa\u672cdocker\u7ba1\u7406\u547d\u4ee4 <\/h3>\n\n\n\n<p><code>docker start &lt;container&gt;<\/code>  \u91cd\u65b0\u555f\u52d5container<\/p>\n\n\n\n<p><code>docker stop &lt;container&gt;<\/code> \u7d42\u6b62\u4e00\u500b\u57f7\u884c\u4e2d\u7684container<\/p>\n\n\n\n<p><code>docker rm &lt;container&gt;<\/code> \u522a\u9664\u4e00\u500b\u8655\u65bc\u7d42\u6b62\u72c0\u614b\u7684\u5bb9\u5668<\/p>\n\n\n\n<p><code>docker ps<\/code> &nbsp; \u67e5\u770b\u5bb9\u5668\u8a0a\u606f&nbsp;&nbsp;<\/p>\n\n\n\n<p><code>docker ps -a<\/code>&nbsp; \u6aa2\u8996\u7d42\u6b62\u72c0\u614b\u7684\u5bb9\u5668&nbsp;<\/p>\n\n\n\n<p><code>docker top<\/code>&nbsp; \u67e5\u770b Container Process<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f7f\u7528image\u555f\u52d5container<\/h3>\n\n\n\n<p><code>#docker run [parameter] &lt; image&gt;&nbsp;&nbsp;<\/code><\/p>\n\n\n\n<p>parameter\u8aaa\u660e\u5982\u4e0b<br>-it: \u4e92\u52d5\u6a21\u5f0f,\u6703\u6709\u8a0a\u606f\u986f\u793a\u51fa\u4f86<br>-d\uff1a\u628a container \u57f7\u884c\u5728\u80cc\u666f\u88e1,\u4e0d\u6703\u6709\u8a0a\u606f\u986f\u793a\u51fa\u4f86<br>&#8211;rm \u8dd1\u5b8c\u5f8c\u522a\u9664<br>&#8211;name &lt; contain name&gt;&nbsp; \u6307\u5b9a\u555f\u52d5\u7684docker\u53eb\u4ec0\u9ebc\u540d\u5b57<br>-e \u50b3\u9001\u7cfb\u7d71\u8b8a\u6578\u9032docker<br>-v \u8a2d\u5b9a\u5171\u4eab\u76ee\u9304<br>-p: \u505a port \u7684mapping\uff0ccontainer\u88e1\u7684port 80 mapping \u5230 host \u76848080 port<br>bash: \u555f\u52d5docker\u5f8c\u4e0d\u57f7\u884c\u9810\u8a2d\u7684\u555f\u52d5script<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u5e38\u898b\u7bc4\u4f8b\u5982\u4e0b<\/h4>\n\n\n\n<p>\u8f38\u51fa\u4e00\u500b \u201cHello World\u201d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo docker run ubuntu:14.04 \/bin\/echo 'Hello world'\nHello world<\/code><\/pre>\n\n\n\n<p>\u555f\u52d5\u4e00\u500b bash<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo docker run -t -i ubuntu:14.04 \/bin\/bash\nroot@af8bae53bdd3:\/#<\/code><\/pre>\n\n\n\n<p>\u80cc\u666f\u57f7\u884cdocker&nbsp;<\/p>\n\n\n\n<p><code>$ sudo docker run -d<\/code><\/p>\n\n\n\n<p>\u57fa\u672c\u7684\u57f7\u884c<\/p>\n\n\n\n<p><code># docker run -it usex\/project:0.1<\/code><\/p>\n\n\n\n<p>docker\u96e2\u958b\u5f8c\u5373\u522a\u9664\u5bb9\u5668<\/p>\n\n\n\n<p><code># docker run -it --rm usex\/project:0.1<\/code><\/p>\n\n\n\n<p>docker\u8207\u672c\u6a5f\u7aef\u958b\u555f\u516c\u4eab\u76ee\u9304<\/p>\n\n\n\n<p><code># docker run -it -v \/local_share_dir\/:\/docker_dir\/ usex\/project:0.1<\/code><\/p>\n\n\n\n<p>\u672c\u6a5f\u7aef\u50b3\u9001\u7cfb\u7d71\u8b8a\u6578\u9032Docker<\/p>\n\n\n\n<p><code># docker run -it -e sysName=\u201dTEST\u201d usex\/project:0.1<\/code><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u555f\u52d5docker\u5f8c\u4e0d\u57f7\u884c\u9810\u8a2d\u7684\u555f\u52d5script<\/p>\n\n\n\n<p><code>#docker run [parameter] &lt; image&gt;&nbsp; bash<\/code><\/p>\n\n\n\n<p>\u8209\u4f8b\u4f86\u8aaa\uff0c\u555f\u52d5docker\u5f8c\u4e0d\u57f7\u884cdockerfile\u5b9a\u7fa9\u7684script <code># docker run -it usex\/project:0.1 bash<\/code><\/p>\n\n\n\n<p>ps:<br>\u5982\u8981\u4f7f\u7528bash,\u5728dockerfile\u88e1\u9762\u8981\u8a2d\u5b9aCMD [\u201csh\u201d]<\/p>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u9032\u5165container<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u65b9\u6cd51<\/h4>\n\n\n\n<p>\u4f7f\u7528\u5bb9\u5668\u5167\u7684\u6307\u4ee4 <code>docker exec&nbsp;<\/code><\/p>\n\n\n\n<p>\u900f\u904ebash\u6307\u4ee4\u64cd\u4f5ccontainer\uff0c\u8209\u4f8b\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo docker run -idt ubuntu\n243c32535da7d142fb0e6df616a3c3ada0b8ab417937c853a9e1c251f499f550\n\n$ sudo docker ps\nCONTAINER ID&nbsp; &nbsp; &nbsp; &nbsp; IMAGE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; COMMAND &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CREATED &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; STATUS&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PORTS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NAMES\n243c32535da7&nbsp; &nbsp; &nbsp; &nbsp; ubuntu:latest &nbsp; &nbsp; &nbsp; \"\/bin\/bash\" &nbsp; &nbsp; &nbsp; &nbsp; 18 seconds ago&nbsp; &nbsp; &nbsp; Up 17 seconds &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nostalgic_hypatia\n\n$sudo docker exec -ti nostalgic_hypatia bash\nroot@243c32535da7:\/#<\/code><\/pre>\n\n\n\n<p>\u76f4\u63a5\u4f7f\u7528container\u5167\u7684\u6307\u4ee4\uff0c\u8209\u4f8b\u5982\u4e0b<\/p>\n\n\n\n<p><code>docker exec -it debian:latest \/bin\/bash<\/code><\/p>\n\n\n\n<p><code>docker exec -it debian:latest \/sbin\/ifconfig<\/code><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u65b9\u6cd52<\/h4>\n\n\n\n<p>\u9032\u5165\u5bb9\u5668\u53ef\u7528<code>docker attach<\/code><\/p>\n\n\n\n<p>\u8209\u4f8b\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo docker run -idt ubuntu\n243c32535da7d142fb0e6df616a3c3ada0b8ab417937c853a9e1c251f499f550\n\n$ sudo docker ps\nCONTAINER ID&nbsp; &nbsp; &nbsp; &nbsp; IMAGE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; COMMAND &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CREATED &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; STATUS&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PORTS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NAMES\n243c32535da7&nbsp; &nbsp; &nbsp; &nbsp; ubuntu:latest &nbsp; &nbsp; &nbsp; \"\/bin\/bash\" &nbsp; &nbsp; &nbsp; &nbsp; 18 seconds ago&nbsp; &nbsp; &nbsp; Up 17 seconds &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nostalgic_hypatia\n\n$sudo docker attach nostalgic_hypatia\nroot@243c32535da7:\/#<\/code><\/pre>\n\n\n\n<p>\u6309\u4e0b ctrl + P \u7136\u5f8c ctrl + Q \u8df3\u96e2\u5bb9\u5668\uff0c\u8b93\u5b83\u7e7c\u7e8c\u5728\u80cc\u666f\u57f7\u884c\u3002<\/p>\n\n\n\n<p>refer<br><a href=\"https:\/\/philipzheng.gitbooks.io\/docker_practice\/content\" target=\"_blank\" rel=\"noopener\">https:\/\/philipzheng.gitbooks.io\/docker_practice\/content<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">docker\u7626\u8eab<\/h3>\n\n\n\n<p>\u6aa2\u8996\u8cc7\u6599\u4f7f\u7528\u72c0\u6cc1<\/p>\n\n\n\n<p><code>#docker system df<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#docker system df\nTYPE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TOTAL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ACTIVE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SIZE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RECLAIMABLE\nImages&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 11&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 7.319 GB&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 7.319 GB (100%)\nContainers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 B &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 B\nLocal Volumes &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 B &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0 B<\/code><\/pre>\n\n\n\n<p>\u522a\u9664\u6240\u6709\u4e0d\u7528\u7684image,container,volumne<\/p>\n\n\n\n<p><code>#docker system prune<\/code><\/p>\n\n\n\n<p>\u5220\u9664\u6ca1\u7528\u7684 image<\/p>\n\n\n\n<p><code>#docker rmi $(docker images -f \"dangling=true\" -q)<\/code><\/p>\n\n\n\n<p>\u5220\u9664 exited container<\/p>\n\n\n\n<p><code>#docker rm -v $(docker ps -a -q -f status=exited)<\/code><\/p>\n\n\n\n<p>\u5220\u9664\u6ca1\u7528\u7684 volumn<\/p>\n\n\n\n<p><code>#docker volume rm $(docker volume ls -qf dangling=true)<\/code><\/p>\n\n\n\n<p>\u65e5\u5fd7\u592a\u5927\uff0c\u522a\u9664container \u65e5\u5fd7<\/p>\n\n\n\n<p><code>#docker stop &lt;container_id><\/code><br><code>#rm \/var\/lib\/docker\/containers\/&lt;container_id>\/&lt;container_id>-json.log<\/code><\/p>\n\n\n\n<p>refer<br><a href=\"https:\/\/www.fengzifz.com\/2017\/03\/27\/clean-docker\" target=\"_blank\" rel=\"noopener\">https:\/\/www.fengzifz.com\/2017\/03\/27\/clean-docker<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker\u662f\u8f15\u91cf\u7d1a\u7684\u865b\u64ec\u5316\u89e3\u6c7a\u65b9\u6848\uff0c\u4f7f\u7528container\u7684\u6280\u8853\uff0c\u985e\u4f3c\u865b\u64ec\u6a5f\u6280\u8853\uff0c\u4f46\u4e0d\u7528\u50cf\u865b\u64ec\u6a5f\u5728\u591a\u6e96\u5099Guest OS<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[19],"tags":[],"class_list":["post-1666","post","type-post","status-publish","format-standard","hentry","category-linuxsystem"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/1666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/comments?post=1666"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/1666\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=1666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=1666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=1666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}