Docker - centos 7 CMD yum命令运行但不安装

时间:2017-01-28 12:09:00

标签: docker centos yum

我对Docker很新,当尝试通过" Dockerfile"安装软件包时我注意到构建步骤已通过,但是当我连接到docker并加载shell时,实际上没有安装任何软件包。

配置:

find_package

构建步骤:

FROM centos:latest
CMD yum -y install epel-release
CMD yum -y install collectd

连接到docker时,两个软件包都没有安装,但是我可以在docker中安装软件包:

Sending build context to Docker daemon 40.45 kB
Step 1/3 : FROM centos:latest
---> 67591570dd29
Step 2/3 : CMD yum -y install epel-release
 ---> Using cache
 ---> 4148233bce10
Step 3/3 : CMD yum -y install collectd
---> Using cache
---> 62998bf2ce0f

请帮忙!

1 个答案:

答案 0 :(得分:4)

使用

 <link rel="stylesheet" href="js/bootstrap.min.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>

<style>
h3{
    font-size: 20px;
    font-family:Verdana;
    color: #515151;
}
img {
     width: 40%;
    }

.carousel-inner {
}

.carousel-caption {
      font-size: 2em;
      right: 10%;
      left: 60%;
      top: 30%;
      bottom: 30%;
      text-align: left;
      text-shadow: none;
     }
.carousel-indicators{
      font-size: 2em;
      bottom: -1%;
      text-align: left;
      text-shadow: none;
        }

/***
 * Bootstrap relies on CSS transitions for animation, which makes it
 * easy to override.  Just add the vertical class to your carousel:
 * <div class='carousel vertical'>...</div>
 ***/

.carousel.vertical .carousel-inner {
  height: 100%;
}
.carousel.vertical .item {
  -webkit-transition: 0.6s ease-in-out top;
  -moz-transition:    0.6s ease-in-out top;
  -ms-transition:     0.6s ease-in-out top;
  -o-transition:      0.6s ease-in-out top;
  left:               0;
}
.carousel.vertical .active,
.carousel.vertical .next.left,
.carousel.vertical .prev.right    { top:     0; }
.carousel.vertical .next,
.carousel.vertical .active.right  { top:  100%; }
.carousel.vertical .prev,
.carousel.vertical .active.left   { top: -100%; }        
</style>
 <div class="container">
                  <h1>Bootstrap Vertical carousel demo</h1>
<asp:Repeater ID="Repeater1" runat="server">
                        <ItemTemplate>


                  <div id="carousel-demo" class="carousel vertical slide" data-ride="carousel" data-interval="2000">
                        <div class="carousel-inner"> 
                         <div class="item"> 
       <img src='<%# DataBinder.Eval(Container.DataItem,"Value") %>' title='<%# (DataBinder.Eval(Container.DataItem,"Text").ToString()).Split('.')[0].ToString() %>' style="margin-top:500px;" alt="">
      <div class="carousel-caption"style="padding-top:500px;">
       <h3>The currant slide</h3>
       <p>Text here</p>
      </div>      
   </div>
</div>


                        </div>
                        </ItemTemplate>
                        </asp:Repeater>

                             </div>


  <!-- Next / Previous controls here -->
  <a class="left carousel-control" href="#carousel-demo" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-up"></span>
  </a>
  <a class="right carousel-control" href="#carousel-demo" data-slide="next">
    <span class="glyphicon glyphicon-chevron-down"></span>
  </a>

 <div>

 </div> 
  </div>


</div>

OR

FROM centos:latest
RUN \
  yum -y install epel-release && \
  yum -y install collectd

RUN

RUN指令允许您安装为其申请的应用程序和程序包。它在当前图像之上执行任何命令,并通过提交结果来创建新图层。

CMD

CMD指令允许您设置默认命令,该命令仅在您运行容器时执行而不指定命令。如果Docker容器使用命令运行,则将忽略默认命令。