{"id":246151,"date":"2022-07-08T09:41:55","date_gmt":"2022-07-08T01:41:55","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=246151"},"modified":"2022-06-29T08:43:34","modified_gmt":"2022-06-29T00:43:34","slug":"docker-create-command","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/docker-create-command.html","title":{"rendered":"Docker create\u547d\u4ee4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nDocker create\u547d\u4ee4\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Docker\u5bb9\u5668\uff0c\u7c7b\u4f3c docker run -d \u547d\u4ee4\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
Docker create\u547d\u4ee4\u8bed\u6cd5<\/strong><\/div>\n
\r\ndocker create [OPTIONS] IMAGE [COMMAND] [ARG...]\r\n<\/pre>\n

\u4f46\u662f\u4e0e docker run -d \u4e0d\u540c\u7684\u662f\uff0cdocker create \u521b\u5efa\u7684\u5bb9\u5668\u5e76\u672a\u5b9e\u9645\u542f\u52a8\uff0c\u8fd8\u9700\u8981\u6267\u884c docker start \u547d\u4ee4\u6216 docker run \u547d\u4ee4\u4ee5\u542f\u52a8\u5bb9\u5668\u3002<\/p>\n

\u4e8b\u5b9e\u4e0a\uff0cdocker create \u547d\u4ee4\u5e38\u7528\u4e8e\u5728\u542f\u52a8\u5bb9\u5668\u4e4b\u524d\u8fdb\u884c\u5fc5\u8981\u7684\u8bbe\u7f6e\u3002<\/p>\n

\u6848\u4f8b<\/strong><\/div>\n
\u521b\u5efa\u5bb9\u5668<\/strong><\/span><\/div>\n

\u4f7f\u7528 docker create \u547d\u4ee4\uff0c\u521b\u5efa docker\u5bb9\u5668\u3002<\/p>\n

\r\nhaicoder(www.haicoder.net)# docker create ubuntu\r\n#\u8fd4\u56de\u62a5\u6587\r\n76f0e8828dcc4dd060819435039adcfbe66f26726ddc9ea58035d0c46420eaaa\r\n<\/pre>\n

\u4f7f\u7528 docker ps \u547d\u4ee4\uff0c\u67e5\u770b\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668\uff0c\u663e\u793a\u5982\u4e0b\u56fe\uff0c\u6240\u793a\uff1a<\/p>\n

\"\"<\/p>\n

\u5373\u6ca1\u6709\u4efb\u4f55\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668\uff0c\u6211\u4eec\u4f7f\u7528 docker ps -a \u547d\u4ee4\uff0c\u67e5\u770b\u5f53\u524d\u6240\u6709\u7684\u5bb9\u5668\u5217\u8868\uff0c\u663e\u793a\u5982\u4e0b\u56fe\uff1a<\/p>\n

\"\"<\/p>\n

\u6211\u4eec\u521a\u521b\u5efa\u7684\u5bb9\u5668\uff0c\u6b64\u65f6\u5df2\u7ecf\u5b58\u5728\uff0c\u53ea\u662f\u6ca1\u6709\u8fd0\u884c\u3002<\/p>\n

\u8fd0\u884c\u5bb9\u5668<\/strong><\/span><\/div>\n

\u4f7f\u7528 docker create \u547d\u4ee4\uff0c\u521b\u5efa docker\u5bb9\u5668\u3002<\/p>\n

\r\nhaicoder(www.haicoder.net)# docker create -it --name haicoder ubuntu bash\r\n#\u8fd4\u56de\u7ed3\u679c\r\n87cdc6386c7d92e3bb2b71f1c50369652ec6809c26aa388de5ef8b29165ff781\r\n<\/pre>\n

\u4f7f\u7528 docker ps\u547d\u4ee4\uff0c\u67e5\u770b\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668\uff0c\u663e\u793a\u5982\u4e0b\u56fe\uff0c\u6240\u793a\uff1a<\/p>\n

\"\"<\/p>\n

\u5373\u6ca1\u6709\u4efb\u4f55\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668\uff0c\u6211\u4eec\u4f7f\u7528 docker ps -a \u547d\u4ee4\uff0c\u67e5\u770b\u5f53\u524d\u6240\u6709\u7684\u5bb9\u5668\u5217\u8868\uff0c\u663e\u793a\u5982\u4e0b\u56fe\uff1a<\/p>\n

\"\"<\/p>\n

\u6211\u4eec\u521a\u521b\u5efa\u7684\u5bb9\u5668\uff0c\u6b64\u65f6\u5df2\u7ecf\u5b58\u5728\uff0c\u53ea\u662f\u6ca1\u6709\u8fd0\u884c\uff0c\u73b0\u5728\u6211\u4eec\u4f7f\u7528 docker start\u547d\u4ee4\uff0c\u542f\u52a8\u521a\u521b\u5efa\u7684 docker\u5bb9\u5668\u3002<\/p>\n

\r\nhaicoder(www.haicoder.net)# docker start -a -i haicoder\r\n[root@392ed39de034 \/]# ls  \r\nanaconda-post.log  bin  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var\r\n[root@392ed39de034 \/]# exit\r\nexit\r\nhaicoder(www.haicoder.net)#\r\n<\/pre>\n

\u4f7f\u7528 docker start \u547d\u4ee4\uff0c\u8fd0\u884c\u5bb9\u5668\u540e\uff0c\u547d\u4ee4\u884c\u7684\u63d0\u793a\u7b26\u53d8\u4e86 docker \u5bb9\u5668\u7684 id\uff0c\u8bf4\u660e\u6b64\u65f6\u5df2\u7ecf\u8fdb\u5165\u4e86 docker \u5bb9\u5668\u5185\u90e8\uff0c\u540c\u65f6\u4f7f\u7528 exit \u547d\u4ee4\uff0c\u9000\u51fa\u5bb9\u5668\u3002<\/p>\n

\u4f7f\u7528 docker rm \u547d\u4ee4\uff0c\u5220\u9664\u6240\u6709 docker \u5bb9\u5668\u3002<\/p>\n

\r\nhaicoder(www.haicoder.net)# docker rm $(docker ps -aq)\r\n#\u8f93\u51fa\u4fe1\u606f\r\n392ed39de034\r\nd267bd988263\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

docker create [OPTIONS] IMAGE [COMMAND] [ARG…] \u4f46\u662f\u4e0e do […]<\/p>\n","protected":false},"author":1903,"featured_media":246163,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-246151","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/246151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1903"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=246151"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/246151\/revisions"}],"predecessor-version":[{"id":246640,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/246151\/revisions\/246640"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/246163"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=246151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=246151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=246151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}