Dockerfile中的命令将如下运行?
docker build Dockerfile .//running it correctly.
1)我已经在注释中提到每个命令都会按照写法执行,这个Dockerfile是否正确工作?
2.)当我运行docker build的时候,这些命令将被用来制作图像
[ec2-user @ ip-xx-xx-xx-xx〜] $ cd / project / p1
[ec2-user @ ip-xx-xx-xx-xx p1] $ ls
Dockerfile abcd
我的Dockerfile由以下命令组成。
Dockerfile
node 8.1.0 //puls the image from hub RUN mkdir -p /etc/x/y //make directory in the host at path /etc/x/y RUN mkdir /app //make directory in the host at path /app COPY . /app //copy all the files that is WORKDIR /app //cd /app; now the working directory will be /app for next commands ie npm install. RUN npm install EXPOSE 3000 //what this will do?
问题1:如何运行docker build?
docker build Dockerfile . # am I running it correctly.
不,你用docker build .
运行它docker build .
Dockerfile
会自动在当前目录下查找Dockerfile
。 或者你使用docker build -f Path_to_the_docker_file/DockerFile
清楚地指定DockerFile
的path。
问题2:修复错误并澄清命令
Dockerfile中有一些错误,检查编辑的注释:
# pulls the image from dockerhub : YES # Needs to be preceeded with FROM FROM node 8.1.0 # all directories are made inside the docker image # make directory in the image at path /etc/x/y : YES RUN mkdir -p /etc/x/y # make directory in the image at path /app : YES RUN mkdir /app COPY . /app # copy all the files that is : YES WORKDIR /app # cd /app; now the working directory will be /app for next commands ie npm install. : YES RUN npm install EXPOSE 3000 # what this will do? => tells all docker instances of this image to listen on port 3000.