docker记录
对于docker已经启动的容器中的服务是否启动的操作
首先进入容器:
docker exec -it CONTAINER_ID bash 进入容器终端并且的保留为容器终端的输入形式(-it和bash的结合作用)
官方解释:
exec: Run a command in a running container(在运行的容器中运行命令)
exec -i: --interactive(相互作用的) Keep STDIN open even if not attached(即使没有连接,也要保持STDIN打开)
exec -t: --tty Allocate a pseudo-TTY(分配一个 冒充的终端设备)
自我理解:
CONTAINER_ID : 容器id只要是能够证明唯一就可以,不用全输入 例子:
我们只输入 be 就可以达到唯一的效果了! docker exec -it be bash 这样就可以
exec: exec + 容器id 就是在选中容器中执行命令 :如 exec be0ab ls 就是在be..的容器中执行ls 就能看见目录结构了
执行效果:
我们还要执行什么就一直要要加 exec be0ab 前缀来执行该容器下的操作 想要去掉就要加上 -it
-it : 目前的理解浅薄,就是要等在容器内的命令执行完毕才会出来到当前操作; 没有-it的加 就相当于在容器内执行一下命令,不等容器内部是否执行完毕直接出来,而我们看见的他在上面是因为容器内的执行快,(行动派可以试试在里面写个循环制造时间验证)
那么就出来了 -it ....bash 的组合
-it ....bash:上面说到在加上-it 会等容器内的操作执行完毕,而bash 是打开容器内的一个终端近程,又因为it的等待 所以就会一直以终端连接的方式停留在容器内部,下面展示效果:
这样就进入了容器的内部 那么我们就能直接的执行相关的命令了
退出的话:
总结:
docker exec -it CONTAINER_ID bash 进入容器终端并且的保留为容器终端的输入形式.
<li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#csdnc-thumbsup"></use>
</svg><span class="name">点赞</span>
<span class="count">4</span>
</a></li>
<li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{"mod":"popu_824"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-Collection-G"></use>
</svg><span class="name">收藏</span></a></li>
<li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-fenxiang"></use>
</svg>分享</a></li>
<!--打赏开始-->
<!--打赏结束-->
<li class="tool-item tool-more">
<a>
<svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
</a>
<ul class="more-box">
<li class="item"><a class="article-report">文章举报</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="person-messagebox">
<div class="left-message"><a href="https://blog.csdn.net/qq_40081976">
<img src="https://profile.csdnimg.cn/8/7/5/3_qq_40081976" class="avatar_pic" username="qq_40081976">
<img src="https://g.csdnimg.cn/static/user-reg-year/2x/2.png" class="user-years">
</a></div>
<div class="middle-message">
<div class="title"><span class="tit"><a href="https://blog.csdn.net/qq_40081976" data-report-click="{"mod":"popu_379"}" target="_blank">小山半白</a></span>
</div>
<div class="text"><span>发布了16 篇原创文章</span> · <span>获赞 61</span> · <span>访问量 18万+</span></div>
</div>
<div class="right-message">
<a href="https://im.csdn.net/im/main.html?userName=qq_40081976" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
</a>
<a class="btn btn-sm bt-button personal-watch" data-report-click="{"mod":"popu_379"}">关注</a>
</div>
</div>
</div>
docker记录