如果我们运行具有.sh文件的dockerfile,“docker build”和“docker run”之间的区别

这是我的Dockerfile

# This Dockerfile describes the standard way to build FROM centos:latest MAINTAINER praveen # Run a root to allow "rpm" USER root WORKDIR /root/ # Get the ACE-TAO rpm from seachange repo COPY TAO-1.7.7-0.x86_64.rpm /root/TAO-1.7.7-0.x86_64.rpm # Insatall the rpm RUN rpm -ivh /root/TAO-1.7.7-0.x86_64.rpm #Start the TAO service #CMD /etc/init.d/tao start COPY namingServiceConfig.sh / RUN /namingServiceConfig.sh EXPOSE 13021 EXPOSE 13022 EXPOSE 13023 ENV NS_PORTS=13021,13022,13023 #ENTRYPOINT /etc/init.d/tao start && bash 

在执行docker build的时候无论是执行shell脚本,还是将部分映像作为部分映像来运行,或者使用docker run来运行映像,它都会反映对容器级别的更改

在我的情况,我怀疑,它正在执行,而dockerbuild设和docker运行两个时间

我使用下面的命令作为build设和通过vagrant文​​件运行的一部分

 d.build_image "/vagrant/tao", args: " -t tao/basic" d.run "tao/basic:latest", args: " -t -d"\ " --name tao-basic"\ " -p 13021:13021"\ " -e NS_PORT=13025,13026,13027" 

让我知道,需要更多的信息

Dockerfile指令(比如RUN等)在构build时被执行(docker docker build -t something .等)。 运行时只有CMDENTRYPOINT指令发生(当容器启动时)。

在您的示例中,shell脚本将作为构build的一部分运行,并且发生的任何更改将作为图像中的新图层提交