生成器运行容器的Docker镜像

我试图find构build和运行Docker镜像和容器的最佳实践。 在下面的例子中,我将引用这个Dockerfile 。

目前我使用这个命令来build立图像:

$ docker build -t <imagename> . 

但是由于一些奇怪的原因,最终运行附着在容器上:

 $ docker build -t hellotrello . [...] Step 13 : RUN ruby hellotrello.rb ---> Running in bf3edd441128 [2015/03/01 19:58:54.750] !! Application Debug message: hellotrello started ^C% $ 

这是通常的? 我其实只是想build立图像,并使用一个单独的命令来启动容器。

不知道现在发生了什么。

你的最后一个命令( RUN ruby hellotrello.rb )应该在你run你的容器时run而不是在构build时run 。 尝试从Dockerfile中删除它,重新生成图像,并运行docker run hellotrello ruby hellotrello.rb

另一个select是将RUN重命名为CMD然后docker run hellotrello (不带参数)。