Docker学习笔记(1)Dockerfile
Dockerfile是制作Docker image的重要方法。
以下是一段代码示例
FROM node //define the base image
LABEL eagleccnu eagleccnu@gmail.com //declares maintainer
RUN git clone -q https://github.com/docker-in-practice/todo.git //clone todo app code
WORKDIR todo //moves to the cloned directory
RUN npm install > /dev/null //Runs the node package manager’s install command (npm)
EXPOSE 8000 //Specifies that containers from the built image should listen on this port
CMD ["npm","start"] // Specifies which command will be run on startup
FROM 指令,用于指定base image. 其余指令的含义,见代码注释。
基于以上Dockerfile制作image的命令是:
docker build .
image生成之后,所得名称一般是一串数字字母,如673a47ce734,可以通过docker tag命令加上一个易于记忆的名称:
docker tag 673a47ce734 todoapp
如此,则image的名称就是todoapp了。

浙公网安备 33010602011771号