\u4ece\u5916\u90e8\u8bbf\u95ee\u5bb9\u5668\u5e94\u7528<\/strong><\/div>\n\u5728\u542f\u52a8\u5bb9\u5668\u7684\u65f6\u5019\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u5bf9\u5e94\u53c2\u6570\uff0c\u5728\u5bb9\u5668\u5916\u90e8\u65e0\u6cd5\u901a\u8fc7\u7f51\u7edc\u8bbf\u95ee\u5bb9\u5668\u5185\u7684\u5e94\u7528\u3002\u9700\u8981\u901a\u8fc7 -p \u53c2\u6570\u6765\u6307\u5b9a\u7aef\u53e3\u6620\u5c04\u3002\u5f53\u4f7f\u7528 -p \u6807\u8bb0\u65f6\uff0cdocker \u4f1a\u968f\u673a\u6620\u5c04\u4e00\u4e2a49000~49900 \u7684\u7aef\u53e3\u5230\u5916\u90e8\u5f00\u653e\u7684\u7f51\u7edc\u7aef\u53e3\u3002<\/p>\n
docker run -d -P training\/webapp python app.py\r\ndocker ps -l<\/pre>\n-p(\u5c0f\u5199)\u8fd9\u53ef\u4ee5\u6307\u5b9a\u8981\u6620\u5c04\u7684\u7aef\u53e3\uff0c\u5e76\u4e14\u5728\u6307\u5b9a\u7aef\u53e3\u4e0a\u53ef\u4ee5\u7ed1\u5b9a\u4e00\u4e2a\u5bb9\u5668\u3002\u683c\u5f0f<\/p>\n
ip:hostPort:containerPort\r\nip::containerPort\r\nhostport:containerPort\r\n<\/pre>\n\u6620\u5c04\u6240\u6709\u63a5\u53e3\u5730\u5740<\/strong><\/div>\n\u4f7f\u7528hostPort:containerPort \u683c\u5f0f\u5c06\u672c\u5730\u76845000\u7aef\u53e3\u6620\u5c04\u5230\u5bb9\u5668\u76845000\u7aef\u53e3<\/p>\n
docker run -d -p 5000:5000 training\/webapp python app.py<\/pre>\n\u6b64\u65f6\u9ed8\u8ba4\u4f1a\u7ed1\u5b9a\u672c\u5730\u6240\u6709\u63a5\u53e3\u4e0a\u7684\u6240\u6709\u5730\u5740\u3002\u591a\u6b21\u4f7f\u7528-p \u53ef\u4ee5\u7ed1\u5b9a\u591a\u4e2a\u7aef\u53e3\u3002<\/p>\n
docker run -d -p 5000:5000 -p 3000:80 training\/webapp python app.py<\/pre>\n\u6620\u5c04\u5230\u6307\u5b9a\u5730\u5740\u7684\u6307\u5b9a\u7aef\u53e3<\/strong><\/div>\n\u53ef\u4ee5\u4f7f\u7528 ip:hostPort:containerPort\u683c\u5f0f\u6307\u5b9a\u6620\u5c04\u4f7f\u7528\u4e00\u4e2a\u7279\u5b9a\u5730\u5740\uff0c\u6bd4\u5982localhost \u5730\u5740127.0.0.1:<\/p>\n
docker run -d -p 127.0.0.1:5000:5000 training\/webapp python app.py<\/pre>\n\u6620\u5c04\u6307\u5b9a\u5730\u5740\u7684\u4efb\u610f\u7aef\u53e3<\/strong><\/div>\n\u4f7f\u7528ip::containerPort\u677f\u9876localhost\u7684\u4efb\u610f\u7aef\u53e3\u5230\u5bb9\u5668\u76845000\u7aef\u53e3\uff0c\u672c\u5730\u4e3b\u673a\u4f1a\u81ea\u52a8\u5206\u914d\u4e00\u4e2a\u7aef\u53e3\u3002<\/p>\n
docker run -d -p 127.0.0.1::5000 training\/webapp python app.py<\/pre>\n\u8fd8\u53ef\u4ee5\u4f7f\u7528udp\u6765\u6307\u5b9audp\u7aef\u53e3\uff1a<\/strong><\/div>\ndocker run -d -p 127.0.0.1:5000:5000\/udp training\/webapp python app.py<\/pre>\n\u67e5\u770b\u94f6\u8272\u7aef\u53e3\u914d\u7f6e<\/strong><\/div>\n\u4f7f\u7528docker port \u6765\u67e5\u770b\u5f53\u524d\u6620\u5c04\u7684\u7aef\u53e3\u914d\u7f6e\u3002\u4e5f\u53ef\u4ee5\u67e5\u770b\u5230\u7ed1\u5b9a\u7684\u5730\u5740\uff1a<\/p>\n
docker port nostalgic_morse 5000<\/pre>\n\u5bb9\u5668\u4e92\u8054\u5b9e\u73b0\u5bb9\u5668\u95f4\u901a\u4fe1<\/strong><\/div>\n\u5bb9\u5668\u7684\u8fde\u63a5\uff08linking\uff09\u7cfb\u7edf\u662f\u9664\u4e86\u7aef\u53e3\u6620\u5c04\u5916\u9886\u4e00\u79cd\u53ef\u4ee5\u4e0e\u5bb9\u5668\u4e2d\u5e94\u7528\u8fdb\u884c\u4ea4\u4e92\u7684\u65b9\u5f0f\u3002\u5b83\u4f1a\u5728\u6e90\u548c\u63a5\u53d7\u5bb9\u5668\u4e4b\u95f4\u521b\u5efa\u4e00\u4e2a\u96a7\u9053\uff0c\u63a5\u6536\u5bb9\u5668\u53ef\u4ee5\u770b\u5230\u6e90\u5bb9\u5668\u6307\u5b9a\u7684\u4fe1\u606f\u3002<\/p>\n
\u81ea\u5b9a\u4e49\u5bb9\u5668\u547d\u540d<\/strong><\/div>\n\u8fde\u63a5\u7cfb\u7edf\u4e00\u53e5\u5bb9\u5668\u7684\u540d\u79f0\u6765\u6267\u884c\u3002\u56e0\u6b64\u3002\u9996\u8981\u81ea\u9876\u4e00\u4e2a\u597d\u51e0\u7684\u5bb9\u5668\u547d\u540d\u3002<\/p>\n
\u867d\u7136\u5f53\u521b\u5efa\u5bb9\u5668\u7684\u65f6\u5019\uff0c\u7cfb\u7edf\u9ed8\u8ba4\u4f1a\u5206\u914d\u4e00\u4e2a\u540d\u5b57\uff0c\u4f46\u81ea\u5b9a\u4e49\u5bb9\u5668\u6709\u4e24\u4e2a\u597d\u5904\uff1a1.\u597d\u8bb0\uff0c2\u4f5c\u4e3a\u6709\u7528\u7684\u53c2\u8003\u70b9\u3002<\/p>\n
docker run -d -P --name web training\/webapp python app.py<\/pre>\n\u4f7f\u7528docker ps \u6765\u9a8c\u8bc1\u8bbe\u5b9a\u7684\u547d\u540d\uff1a<\/strong><\/div>\ndocker ps -l<\/pre>\n\u4e5f\u53ef\u4ee5\u4f7f\u7528docker inspect \u6765\u67e5\u770b\u5bb9\u5668\u7684\u540d\u5b57\uff1a<\/strong><\/div>\ndocker inspect -f \"{{.Name}}\" aed84ee21bde<\/pre>\n\u5728\u6267\u884cdocker run \u7684\u65f6\u5019\u5982\u679c\u6dfb\u52a0--rm\u6807\u8bb0\uff0c\u5219\u5bb9\u5668\u5728\u7ec8\u6b62\u540e\u4f1a\u7acb\u5373\u5220\u9664\uff0c\u6ce8\u610f --rm \u548c-d \u53c2\u6570\u4e0d\u80fd\u540c\u65f6\u4f7f\u7528\u3002<\/p>\n
\u5bb9\u5668\u4e92\u8054<\/strong><\/div>\n\u4f7f\u7528 --link \u53c2\u6570\u53ef\u4ee5\u8ba9\u5bb9\u5668\u4e4b\u95f4\u5b89\u5168\u7684\u8fdb\u884c\u4ea4\u4e92\u3002<\/p>\n
\u4e0b\u9762\u5148\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93\u5bb9\u5668\uff1b<\/strong><\/div>\ndocker run -d --name db training\/postgres<\/pre>\n\u5220\u9664\u4e4b\u524d\u7684web\u5bb9\u5668\uff1a<\/strong><\/div>\ndocker rm -f web<\/pre>\n\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u65b0\u7684web\u5bb9\u5668\uff0c\u5e76\u5c06\u5b83\u8fde\u63a5\u5230db\u5bb9\u5668<\/strong><\/div>\ndocker run -d -P --name web --link db:db training\/webapp python app.py<\/pre>\n\u6b64\u65f6\uff0cdb \u5bb9\u5668\u548cweb\u5bb9\u5668\u5efa\u7acb\u4e92\u8054\u5173\u7cfb\u3002<\/p>\n
--link \u53c2\u6570\u7684\u683c\u5f0f: --link name:alias\uff0c\u5176\u4e2dname\u662f\u8981\u8fde\u63a5\u7684\u5bb9\u5668\u7684\u540d\u79f0\uff0calias \u662f\u8fd9\u4e2a\u94fe\u63a5\u7684\u522b\u540d\u3002<\/p>\n
\u4f7f\u7528 docker ps \u67e5\u770b\u5bb9\u5668\u7684\u8fde\u63a5<\/strong><\/div>\ndocker ps<\/pre>\n","protected":false},"excerpt":{"rendered":"\u5927\u91cf\u7684\u4e92\u8054\u7f51\u5e94\u7528\u670d\u52a1\u5305\u62ec\u591a\u4e2a\u670d\u52a1\u7ec4\u4ef6\uff0c\u8fd9\u5f80\u5f80\u9700\u8981\u591a\u4e2a\u5bb9\u5668\u4e4b\u95f4\u901a\u8fc7\u7f51\u7edc\u901a\u4fe1\u8fdb\u884c\u76f8\u4e92\u914d\u5408\u3002 Docker\u76ee\u524d\u63d0\u4f9b\u4e86 […]<\/p>\n","protected":false},"author":1469,"featured_media":241277,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-241271","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\/241271","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\/1469"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=241271"}],"version-history":[{"count":7,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241271\/revisions"}],"predecessor-version":[{"id":241565,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241271\/revisions\/241565"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/241277"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=241271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=241271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=241271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}