id: a116c9a0c09f4c5b95ff1eb7a7997656
parent_id: 
item_type: 1
item_id: b42792380c05400d8d68a872bc965052
item_updated_time: 1764345501055
title_diff: "[{\"diffs\":[[1,\"Docker run 命令  菜鸟教程\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":19}]"
body_diff: "[{\"diffs\":[[1,\"<html>\\\r\\\n<head>\\\r\\\n  <title>Docker run 命令 | 菜鸟教程</title>\\\r\\\n  <basefont face=\\\"微软雅黑\\\" size=\\\"2\\\" />\\\r\\\n  <meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html;charset=utf-8\\\" />\\\r\\\n  <meta name=\\\"exporter-version\\\" content=\\\"YXBJ Windows/608924 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;\\\"/>\\\r\\\n  <style>\\\r\\\n\\tbody, td {\\\r\\\n\\t  font-family: 微软雅黑;\\\r\\\n\\t  font-size: 12pt;\\\r\\\n\\t}\\\r\\\n  </style>\\\r\\\n</head>\\\r\\\n<body>\\\r\\\n<a name=\\\"29791\\\"></a>\\\r\\\n<h1>Docker run 命令 | 菜鸟教程</h1>\\\r\\\n\\\r\\\n<div><span>\\\n  <div style=\\\"--en-clipped-content:simplified; --en-clipped-source-url:https://www.runoob.com/docker/docker-run-command.html; --en-clipped-source-title:Docker run 命令 | 菜鸟教程;\\\">\\\n<div><br/></div><div style=\\\"min-height: 1559px; font-size: 16px; display: block; min-width: 100%; position: relative;\\\"> <div style=\\\"background-color:transparent;font:inherit;vertical-align:baseline;\\\"><div style=\\\"background-color:transparent;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;font-size:16px;line-height:1.5em;color:rgb(31, 9, 9);text-align:left;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;width:36em;z-index:200;padding-left:2em;padding-right:2em;margin-left:auto;margin-right:auto;position:relative;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;position:relative;margin-left:-25px;margin-right:25px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;padding-top:0px;padding-bottom:9em;position:relative;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;position:relative;margin-bottom:0px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><h1 style=\\\"font-family:&quot;PT Serif&quot;;text-align:left;border:0px;font:inherit;vertical-align:baseline;font-size:35px;font-weight:normal;line-height:35px;margin-bottom:20px;padding:0px;margin:0px;\\\">Docker run 命令</h1><div style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;position:relative;height:1em;line-height:1;text-align:center;margin:0px;padding-top:1.5em;padding-bottom:1.5em;margin-bottom:0px;\\\"><div style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;background:-webkit-linear-gradient(0deg, rgb(243, 242, 238) 1%, rgb(31, 9, 9) 50%, rgb(243, 242, 238) 99%);position:absolute;left:-4em;top:50%;z-index:10;width:100%;padding-left:4em;padding-right:4em;height:0.1em;opacity:0.5;margin:0px;margin-bottom:0px;\\\"><span style=\\\"font:inherit;position:absolute;left:-4em;top:50%;z-index:10;width:100%;padding-left:4em;padding-right:4em;height:0.1em;margin:0px;opacity:0.5;background:-webkit-linear-gradient(0deg, rgb(243, 242, 238) 1%, rgb(31, 9, 9) 50%, rgb(243, 242, 238) 99%);\\\"></span></div></div></div>\\\n<hr style=\\\"border-color:rgb(31, 9, 9);border-top:none;border-right:none;border-bottom:1px solid;border-left:none;\\\"/>\\\n\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">docker run ：</strong>创建一个新的容器并运行一个命令</p>\\\n<h3 style=\\\"font-family:&quot;PT Serif&quot;;text-align:left;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-size:30px;line-height:35px;margin-top:35px;font-weight:normal;margin-bottom:15px;\\\">语法</h3>\\\n<pre style=\\\"background-color:rgb(243, 242, 238);font-family:Inconsolata;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;width:auto;font-size:0.875em;line-height:1.71429em;\\\">docker run [OPTIONS] IMAGE [COMMAND][ARG...]</pre>\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">OPTIONS说明：</p>\\\n<ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;margin-top:-1em;list-style-type:none;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">-a stdin:</strong> 指定标准输入输出内容类型，可选 STDIN/STDOUT/STDERR 三项；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\"><span style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(234, 226, 96);transition:background-color 0.4s ease 0s;color:black;font-weight:inherit;font-style:unset;-evernote-highlight:true;\\\" title=\\\"点击以取消高亮显示\\\">-d:</span></strong><span style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(234, 226, 96);transition:background-color 0.4s ease 0s;color:black;font-weight:inherit;font-style:unset;-evernote-highlight:true;\\\" title=\\\"点击以取消高亮显示\\\"> 后台运行容器，并返回容器ID；</span></p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">-i:</strong> 以交互模式运行容器，通常与 -t 同时使用；</p>\\\n</li>\\\n<li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\"><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">-P:</strong> 随机端口映射，容器内部端口<strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">随机</strong>映射到主机的端口</p>\\\n</li>\\\n<li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\"><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">-p:</strong> 指定端口映射，格式为：主机(宿主)端口:容器端口 </p>\\\n</li>\\\n<li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">-t:</strong> 为容器重新分配一个伪输入终端，通常与 -i 同时使用；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\"><span style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(234, 226, 96);transition:background-color 0.4s ease 0s;color:black;font-weight:inherit;font-style:unset;-evernote-highlight:true;\\\" title=\\\"点击以取消高亮显示\\\">--name=&quot;nginx-lb&quot;:</span></strong><span style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(234, 226, 96);transition:background-color 0.4s ease 0s;color:black;font-weight:inherit;font-style:unset;-evernote-highlight:true;\\\" title=\\\"点击以取消高亮显示\\\"> 为容器指定一个名称；</span></p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">--dns 8.8.8.8:</strong> 指定容器使用的DNS服务器，默认和宿主一致；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">--dns-search example.com:</strong> 指定容器DNS搜索域名，默认和宿主一致；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">-h &quot;mars&quot;:</strong> 指定容器的hostname；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">-e username=&quot;ritchie&quot;:</strong> 设置环境变量；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">--env-file=[]:</strong> 从指定文件读入环境变量；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">--cpuset=&quot;0-2&quot; or --cpuset=&quot;0,1,2&quot;:</strong> 绑定容器到指定CPU运行；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">-m :</strong>设置容器使用内存最大值；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">--net=&quot;bridge&quot;:</strong> 指定容器的网络连接类型，支持 bridge/host/none/container: 四种类型；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">--link=[]:</strong> 添加链接到另一个容器；</p>\\\n</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">--expose=[]:</strong> 开放一个端口或一组端口；\\\n</p></li>\\\n<li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\"><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><strong style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">--volume , -v:\\t</strong> 绑定一个卷</p></li>\\\n\\\n\\\n</ul>\\\n\\\n<h3 style=\\\"font-family:&quot;PT Serif&quot;;text-align:left;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-size:30px;line-height:35px;margin-top:35px;font-weight:normal;margin-bottom:15px;\\\">实例</h3>\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">使用docker镜像nginx:latest以后台模式启动一个容器,并将容器命名为mynginx。</p>\\\n<pre style=\\\"background-color:rgb(243, 242, 238);font-family:Inconsolata;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;width:auto;font-size:0.875em;line-height:1.71429em;\\\">docker run --name mynginx -d nginx:latest</pre>\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">使用镜像nginx:latest以后台模式启动一个容器,并将容器的80端口映射到主机随机端口。</p>\\\n<pre style=\\\"background-color:rgb(243, 242, 238);font-family:Inconsolata;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;width:auto;font-size:0.875em;line-height:1.71429em;\\\">docker run -P -d nginx:latest</pre>\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">使用镜像 nginx:latest，以后台模式启动一个容器,将容器的 80 端口映射到主机的 80 端口,主机的目录 /data 映射到容器的 /data。</p>\\\n<pre style=\\\"background-color:rgb(243, 242, 238);font-family:Inconsolata;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;width:auto;font-size:0.875em;line-height:1.71429em;\\\">docker run -p 80:80-v /data:/data -d nginx:latest</pre>\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">绑定容器的 8080 端口，并将其映射到本地主机 127.0.0.1 的 80 端口上。</p>\\\n<pre style=\\\"background-color:rgb(243, 242, 238);font-family:Inconsolata;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;width:auto;font-size:0.875em;line-height:1.71429em;\\\">$ docker run -p 127.0.0.1:80:8080/tcp ubuntu bash</pre>\\\n<p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">使用镜像nginx:latest以交互模式启动一个容器,在容器内执行/bin/bash命令。</p>\\\n<pre style=\\\"background-color:rgb(243, 242, 238);font-family:Inconsolata;margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;width:auto;font-size:0.875em;line-height:1.71429em;\\\">runoob@runoob:~$ docker run -it nginx:latest /bin/bash\\\nroot@b8573233d675:/#</pre>\\\n\\\n\\\n<hr style=\\\"border-color:rgb(31, 9, 9);border-top:none;border-right:none;border-bottom:1px solid;border-left:none;\\\"/>\\\n<br/><br/></div></div></div></div></div></div></div></div></div></div>\\\n</div>\\\n</span>\\\n</div></body></html>\\u0000\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":14984}]"
metadata_diff: {"new":{"id":"b42792380c05400d8d68a872bc965052","parent_id":"061de1401cfc4cfaadf6e74e015970e9","latitude":"0.00000000","longitude":"0.00000000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin-desktop","source_application":"net.cozic.joplin-desktop","application_data":"","order":1764345716967,"markup_language":2,"is_shared":0,"share_id":"","conflict_original_id":"","master_key_id":"","user_data":"","deleted_time":0},"deleted":[]}
encryption_cipher_text: 
encryption_applied: 0
updated_time: 2025-11-28T16:12:37.169Z
created_time: 2025-11-28T16:12:37.169Z
type_: 13