Docker之常用命令
来源:互联网 发布:部落冲突弹跳药水数据 编辑:程序博客网 时间:2024/05/21 21:41
<h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';"></span></h2><pre class="bash" name="code" style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(102, 102, 102); line-height: 26px; white-space: pre-wrap; font-size: 14px; background-color: rgb(255, 255, 255);"><h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">1. 查看docker信息(version、info)</span></h2><div class="dp-highlighter bg_plain" style="word-wrap: break-word; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 700.906px; overflow: auto; padding-top: 1px; color: rgb(51, 51, 51); white-space: normal; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="word-wrap: break-word; padding-left: 45px;"><div class="tools" style="word-wrap: break-word; padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word;">[plain]</span> <a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="ViewSource" title="view plain" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">view plain</a><a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="CopyToClipboard" title="copy" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">copy</a><div style="word-wrap: break-word; position: absolute; left: 493px; top: 458px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1" style="word-wrap: break-word; margin: 0px 0px 1px 45px !important; padding: 0px; list-style: none; border: none; color: rgb(92, 92, 92); background-color: rgb(255, 255, 255);"><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 查看docker版本 </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker version </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 显示docker系统的信息 </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker info </span></li></ol></div><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><a target=_blank name="t1" style="word-wrap: break-word; color: rgb(86, 86, 86);"></a><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">2. 对image的操作(search、pull、images、rmi、history)</span></h2><div class="dp-highlighter bg_plain" style="word-wrap: break-word; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 700.906px; overflow: auto; padding-top: 1px; color: rgb(51, 51, 51); white-space: normal; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="word-wrap: break-word; padding-left: 45px;"><div class="tools" style="word-wrap: break-word; padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word;">[plain]</span> <a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="ViewSource" title="view plain" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">view plain</a><a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="CopyToClipboard" title="copy" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">copy</a><div style="word-wrap: break-word; position: absolute; left: 493px; top: 683px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1" style="word-wrap: break-word; margin: 0px 0px 1px 45px !important; padding: 0px; list-style: none; border: none; color: rgb(92, 92, 92); background-color: rgb(255, 255, 255);"><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 检索image </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker search image_name </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 下载image </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker pull image_name </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 列出镜像列表; -a, --all=false Show all images; --no-trunc=false Don't truncate output; -q, --quiet=false Only show numeric IDs </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker images </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 删除一个或者多个镜像; -f, --force=false Force; --no-prune=false Do not delete untagged parents </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker rmi image_name </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 显示一个镜像的历史; --no-trunc=false Don't truncate output; -q, --quiet=false Only show numeric IDs </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker history image_name </span></li></ol></div><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><a target=_blank name="t2" style="word-wrap: break-word; color: rgb(86, 86, 86);"></a><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">3. 启动容器(run)</span></h2><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">docker容器可以理解为在沙盒中运行的进程。这个沙盒包含了该进程运行所必须的资源,包括文件系统、系统类库、shell 环境等等。但这个沙盒默认是不会运行任何程序的。你需要在沙盒中运行一个进程来启动某一个容器。这个进程是该容器的唯一进程,所以当该进程结束的时候,容器也会完全的停止。</span></p><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><div class="dp-highlighter bg_plain" style="word-wrap: break-word; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 700.906px; overflow: auto; padding-top: 1px; color: rgb(51, 51, 51); white-space: normal; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="word-wrap: break-word; padding-left: 45px;"><div class="tools" style="word-wrap: break-word; padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word;">[plain]</span> <a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="ViewSource" title="view plain" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">view plain</a><a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="CopyToClipboard" title="copy" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">copy</a><div style="word-wrap: break-word; position: absolute; left: 493px; top: 1216px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1" style="word-wrap: break-word; margin: 0px 0px 1px 45px !important; padding: 0px; list-style: none; border: none; color: rgb(92, 92, 92); background-color: rgb(255, 255, 255);"><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 在容器中运行"echo"命令,输出"hello word" </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker run image_name echo "hello word" </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 交互式进入容器中 </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker run -i -t image_name /bin/bash </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 在容器中安装新的程序 </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker run image_name apt-get install -y app_name </span></li></ol></div><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">Note: 在执行apt-get 命令的时候,要带上-y参数。如果不指定-y参数的话,apt-get命令会进入交互模式,需要用户输入命令来进行确认,但在docker环境中是无法响应这种交互的。apt-get 命令执行完毕之后,容器就会停止,但对容器的改动不会丢失。</span></p><h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><a target=_blank name="t3" style="word-wrap: break-word; color: rgb(86, 86, 86);"></a><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">4. 查看容器(ps)</span></h2><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><div class="dp-highlighter bg_plain" style="word-wrap: break-word; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 700.906px; overflow: auto; padding-top: 1px; color: rgb(51, 51, 51); white-space: normal; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="word-wrap: break-word; padding-left: 45px;"><div class="tools" style="word-wrap: break-word; padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word;">[plain]</span> <a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="ViewSource" title="view plain" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">view plain</a><a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="CopyToClipboard" title="copy" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">copy</a><div style="word-wrap: break-word; position: absolute; left: 493px; top: 1605px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1" style="word-wrap: break-word; margin: 0px 0px 1px 45px !important; padding: 0px; list-style: none; border: none; color: rgb(92, 92, 92); background-color: rgb(255, 255, 255);"><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 列出当前所有正在运行的container </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker ps </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 列出所有的container </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker ps -a </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 列出最近一次启动的container </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker ps -l </span></li></ol></div><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><a target=_blank name="t4" style="word-wrap: break-word; color: rgb(86, 86, 86);"></a><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">5. 保存对容器的修改(commit)</span></h2><span style="word-wrap: break-word; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">当你对某一个容器做了修改之后(通过在容器中运行某一个命令),可以把对容器的修改保存下来,这样下次可以从保存后的最新状态运行该容器。</span></span><span style="word-wrap: break-word; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"></span><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><div class="dp-highlighter bg_plain" style="word-wrap: break-word; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 700.906px; overflow: auto; padding-top: 1px; color: rgb(51, 51, 51); white-space: normal; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="word-wrap: break-word; padding-left: 45px;"><div class="tools" style="word-wrap: break-word; padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word;">[plain]</span> <a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="ViewSource" title="view plain" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">view plain</a><a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="CopyToClipboard" title="copy" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">copy</a><div style="word-wrap: break-word; position: absolute; left: 493px; top: 1900px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1" style="word-wrap: break-word; margin: 0px 0px 1px 45px !important; padding: 0px; list-style: none; border: none; color: rgb(92, 92, 92); background-color: rgb(255, 255, 255);"><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 保存对容器的修改; -a, --author="" Author; -m, --message="" Commit message </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker commit ID new_image_name </span></li></ol></div><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">Note: image相当于类,container相当于实例,不过可以动态给实例安装新软件,然后把这个container用commit命令固化成一个image。</span></p><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><a target=_blank name="t5" style="word-wrap: break-word; color: rgb(86, 86, 86);"></a><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">6. 对容器的操作(rm、stop、start、kill、logs、diff、top、cp、restart、attach)</span></h2><div class="dp-highlighter bg_plain" style="word-wrap: break-word; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 700.906px; overflow: auto; padding-top: 1px; color: rgb(51, 51, 51); white-space: normal; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="word-wrap: break-word; padding-left: 45px;"><div class="tools" style="word-wrap: break-word; padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word;">[plain]</span> <a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="ViewSource" title="view plain" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">view plain</a><a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="CopyToClipboard" title="copy" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">copy</a><div style="word-wrap: break-word; position: absolute; left: 493px; top: 2163px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1" style="word-wrap: break-word; margin: 0px 0px 1px 45px !important; padding: 0px; list-style: none; border: none; color: rgb(92, 92, 92); background-color: rgb(255, 255, 255);"><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 删除所有容器 </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker rm `docker ps -a -q` </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 删除单个容器; -f, --force=false; -l, --link=false Remove the specified link and not the underlying container; -v, --volumes=false Remove the volumes associated to the container </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker rm Name/ID </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 停止、启动、杀死一个容器 </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker stop Name/ID </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker start Name/ID </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker kill Name/ID </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 从一个容器中取日志; -f, --follow=false Follow log output; -t, --timestamps=false Show timestamps </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker logs Name/ID </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 列出一个容器里面被改变的文件或者目录,list列表会显示出三种事件,A 增加的,D 删除的,C 被改变的 </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker diff Name/ID </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 显示一个运行的容器里面的进程信息 </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker top Name/ID </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 从容器里面拷贝文件/目录到本地一个路径 </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker cp Name:/container_path to_path </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker cp ID:/container_path to_path </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 重启一个正在运行的容器; -t, --time=10 Number of seconds to try to stop for before killing the container, Default=10 </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker restart Name/ID </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 附加到一个运行的容器上面; --no-stdin=false Do not attach stdin; --sig-proxy=true Proxify all received signal to the process </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker attach ID </span></li></ol></div><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;">Note: attach命令允许你查看或者影响一个运行的容器。你可以在同一时间attach同一个容器。你也可以从一个容器中脱离出来,是从CTRL-C。</p><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><a target=_blank name="t6" style="word-wrap: break-word; color: rgb(86, 86, 86);"></a><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">7. 保存和加载镜像(save、load)</span></h2><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">当需要把一台机器上的镜像迁移到另一台机器的时候,需要保存镜像与加载镜像。</span></p><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><div class="dp-highlighter bg_plain" style="word-wrap: break-word; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 700.906px; overflow: auto; padding-top: 1px; color: rgb(51, 51, 51); white-space: normal; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="word-wrap: break-word; padding-left: 45px;"><div class="tools" style="word-wrap: break-word; padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word;">[plain]</span> <a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="ViewSource" title="view plain" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">view plain</a><a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="CopyToClipboard" title="copy" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">copy</a><div style="word-wrap: break-word; position: absolute; left: 493px; top: 3016px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1" style="word-wrap: break-word; margin: 0px 0px 1px 45px !important; padding: 0px; list-style: none; border: none; color: rgb(92, 92, 92); background-color: rgb(255, 255, 255);"><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 保存镜像到一个tar包; -o, --output="" Write to an file </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker save image_name -o file_path </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 加载一个tar包格式的镜像; -i, --input="" Read from a tar archive file </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker load -i file_path </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 机器a </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker save image_name > /home/save.tar </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 使用scp将save.tar拷到机器b上,然后: </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker load < /home/save.tar </span></li></ol></div><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><a target=_blank name="t7" style="word-wrap: break-word; color: rgb(86, 86, 86);"></a><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">8、 登录registry server(login)</span></h2><div class="dp-highlighter bg_plain" style="word-wrap: break-word; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 700.906px; overflow: auto; padding-top: 1px; color: rgb(51, 51, 51); white-space: normal; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="word-wrap: break-word; padding-left: 45px;"><div class="tools" style="word-wrap: break-word; padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word;">[plain]</span> <a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="ViewSource" title="view plain" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">view plain</a><a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="CopyToClipboard" title="copy" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">copy</a><div style="word-wrap: break-word; position: absolute; left: 493px; top: 3313px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1" style="word-wrap: break-word; margin: 0px 0px 1px 45px !important; padding: 0px; list-style: none; border: none; color: rgb(92, 92, 92); background-color: rgb(255, 255, 255);"><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 登陆registry server; -e, --email="" Email; -p, --password="" Password; -u, --username="" Username </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker login </span></li></ol></div><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><a target=_blank name="t8" style="word-wrap: break-word; color: rgb(86, 86, 86);"></a><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">9. 发布image(push)</span></h2><div class="dp-highlighter bg_plain" style="word-wrap: break-word; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 700.906px; overflow: auto; padding-top: 1px; color: rgb(51, 51, 51); white-space: normal; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="word-wrap: break-word; padding-left: 45px;"><div class="tools" style="word-wrap: break-word; padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word;">[plain]</span> <a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="ViewSource" title="view plain" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">view plain</a><a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="CopyToClipboard" title="copy" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">copy</a><div style="word-wrap: break-word; position: absolute; left: 493px; top: 3502px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1" style="word-wrap: break-word; margin: 0px 0px 1px 45px !important; padding: 0px; list-style: none; border: none; color: rgb(92, 92, 92); background-color: rgb(255, 255, 255);"><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"># 发布docker镜像 </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker push new_image_name </span></li></ol></div><h2 style="word-wrap: break-word; margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><a target=_blank name="t9" style="word-wrap: break-word; color: rgb(86, 86, 86);"></a><span style="word-wrap: break-word; font-family: 'Microsoft YaHei';">10. 根据Dockerfile 构建出一个容器</span></h2><p style="word-wrap: break-word; margin-top: 5px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: Arial; white-space: normal;"><br style="word-wrap: break-word;" /></p><div class="dp-highlighter bg_plain" style="word-wrap: break-word; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; width: 700.906px; overflow: auto; padding-top: 1px; color: rgb(51, 51, 51); white-space: normal; margin: 18px 0px !important; background-color: rgb(231, 229, 220);"><div class="bar" style="word-wrap: break-word; padding-left: 45px;"><div class="tools" style="word-wrap: break-word; padding: 3px 8px 10px 10px; font-size: 9px; line-height: normal; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; border-left-width: 3px; border-left-style: solid; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word;">[plain]</span> <a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="ViewSource" title="view plain" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_plain.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">view plain</a><a target=_blank href="http://blog.csdn.net/we_shell/article/details/38368137#" class="CopyToClipboard" title="copy" style="word-wrap: break-word; text-decoration: none; color: rgb(160, 160, 160); border: none; padding: 1px; margin: 0px 10px 0px 0px; font-size: 9px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-image: url(http://static.blog.csdn.net/.s/SyntaxHighlighter/styles/images/default/ico_copy.gif); background-color: inherit; background-position: 0% 0%; background-repeat: no-repeat;">copy</a><div style="word-wrap: break-word; position: absolute; left: 493px; top: 3659px; width: 18px; height: 18px; z-index: 99;"></div></div></div><ol start="1" style="word-wrap: break-word; margin: 0px 0px 1px 45px !important; padding: 0px; list-style: none; border: none; color: rgb(92, 92, 92); background-color: rgb(255, 255, 255);"><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">#build </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> --no-cache=false Do not use cache when building the image </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> -q, --quiet=false Suppress the verbose output generated by the containers </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> --rm=true Remove intermediate containers after a successful build </span></li><li class="alt" style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); color: inherit; line-height: 18px;"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"> -t, --tag="" Repository name (and optionally a tag) to be applied to the resulting image in case of success </span></li><li style="word-wrap: break-word; margin: 0px !important; padding: 0px 3px 0px 10px !important; list-style: decimal-leading-zero outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); line-height: 18px; background-color: rgb(248, 248, 248);"><span style="word-wrap: break-word; margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">$docker build -t image_name Dockerfile_path </span></li><li></li></ol></div>
0 0
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- Docker之常用命令
- docker之常用命令整理
- Docker之常用命令
- docker学习之三docker常用命令
- docker学习总结之常用命令
- DOCKER学习之(二) 容器部分常用命令
- 2016SDAU编程练习三1012
- iOS之单例模式常见写法
- Android Service的Binder通信机制
- 大数相加 C/C++
- Okhttp session持久化
- Docker之常用命令
- LVDS接口详解
- 2016SDAU编程练习三1013
- super init
- 数据库学习之旅——实验3(1)
- 最优三角剖分
- 设计模式之适配器模式
- 笔试题58. LeetCode OJ (45)
- JAVA线程-线程间通信