docker build -f /path/to/a/Dockerfile -t shykes/myapp:1.0.2 -t shykes/myapp:latest .
可以指定 Dockerfile 文件位置以及可以增加多个 tag
# this is a Comment FROM <image>@<digest>
MAINTAINER <name>
用来标识 Image 的维护者
# 默认使用 /bin/sh -c 运行 RUN <command> # 可以使用 / 换行 RUN /bin/bash -c 'source $HOME/.bashrc ;/ echo $HOME' RUN ["executable", "param1", "param2"] # exec 模式,下面的 $HOME 不会被正确替换 RUN [ "echo", "$HOME" ] # 使用这种方式 RUN [ "sh", "-c", "echo", "$HOME" ]
# 共有三种模式 CMD ["executable","param1","param2"] CMD ["param1","param2"] CMD command param1 param2
LABEL "com.example.vendor"="ACME Incorporated" LABEL com.example.label-with-value="foo" LABEL version="1.0" LABEL description="This text illustrates / that label-values can span multiple lines."
LABEL multi.label1="value1" multi.label2="value2" other="value3" LABEL multi.label1="value1" / multi.label2="value2" / other="value3"
EXPOSE <port> [<port>...]
ENV myName John Doe ENV myDog Rex The Dog ENV myCat fluffy
# 有两种用法 ADD <src>... <dest> ADD ["<src>",... "<dest>"]
ENTRYPOINT ["executable", "param1", "param2"] ENTRYPOINT command param1 param2
ENTRYPOINT VS CMD
VOLUME ["/data"]
USER daemon
# WORKDIR /path/to/workdir WORKDIR /a WORKDIR b WORKDIR c RUN pwd # path is /a/b/c
ARG <name>[=<default value>] FROM busybox ARG user1 ARG buildno=1