Dockerfile详解
2016-08-09 14:17
761 查看
环境置换
可通过env设置环境变量,然后在Dockerfile中使用。
用法:
${variable:-word} 指示如果设置了变量,则结果将是该值。如果变量是不设置,那么这个word将是结果。
${variable:+word} 指示如果变量设置为“设置”,则将是结果 ,否则结果为空字符串。
可使用环境置换的Dockerfile参数:ADD、COPY、ENV、EXPOSE、LABEL、USER、WORKDIR、VOLUME、STOPSIGNAL、ONBUILD
BUILD
docker build --no-cache 清除缓存
.dockerignore file
说明:你可以添加一个 .dockerignore 文件到你的 `Dockerfile` , Docker 将会在发送构建上下文到守护进程时忽略在 .dockerignore 中指定的文件和目录。
# comment
*/temp*
*/*/temp*
temp?
RUN
For example:
ENTRYPOINT
VOLUME ["/data1","/data2"]
HEALTHCHECK
HEALTHCHECK --interval=5m --timeout=3s \
CMD curl -f http://localhost/ || exit 1
状态码:
0: success - the container is healthy and ready for use
1: unhealthy - the container is not working correctly
2: reserved - do not use this exit code
可通过env设置环境变量,然后在Dockerfile中使用。
用法:
${variable:-word} 指示如果设置了变量,则结果将是该值。如果变量是不设置,那么这个word将是结果。
${variable:+word} 指示如果变量设置为“设置”,则将是结果 ,否则结果为空字符串。
可使用环境置换的Dockerfile参数:ADD、COPY、ENV、EXPOSE、LABEL、USER、WORKDIR、VOLUME、STOPSIGNAL、ONBUILD
BUILD
docker build --no-cache 清除缓存
CMD
三种格式:CMD ["executable","param1","param2"](exec form, this is the preferred form)
CMD ["param1","param2"](as default parameters to ENTRYPOINT)
CMD command param1 param2(shell form)
.dockerignore file
说明:你可以添加一个 .dockerignore 文件到你的 `Dockerfile` , Docker 将会在发送构建上下文到守护进程时忽略在 .dockerignore 中指定的文件和目录。
# comment
*/temp*
*/*/temp*
temp?
RUN
RUN <command>
RUN ["executable", "param1", "param2"]
ENV
ENV <key> <value> ENV <key>=<value> ...
For example:
ENV myName="John Doe" myDog=Rex\ The\ Dog \ myCat=fluffy
ENTRYPOINT
ENTRYPOINT ["executable", "param1", "param2"](exec form, preferred)
ENTRYPOINT command param1 param2(shell form)
VOLUME
VOLUME ["/data"]
VOLUME ["/data1","/data2"]
HEALTHCHECK
HEALTHCHECK --interval=5m --timeout=3s \
CMD curl -f http://localhost/ || exit 1
状态码:
0: success - the container is healthy and ready for use
1: unhealthy - the container is not working correctly
2: reserved - do not use this exit code
相关文章推荐
- centos6.5上安装docker
- 在kubernetes上实现tomcat日志的持久化
- docker容器的网络信息查看
- openstack kilo-with-dokcer
- 在windows下的安装Docker的教程
- 8个你可能不知道的Docker知识
- mysql 5.7 docker 主从复制架构搭建教程
- 在Docker中自动化部署Ruby on Rails的教程
- 搭建基于Docker的PHP开发环境的详细教程
- Docker容器的Tengine实践
- 利用OpenVSwitch在多台主机上部署Docker的教程
- ubuntu14.04+docker的安装及使用
- Docker 清理命令集锦
- 再Docker中架设完整的WordPress站点全攻略
- 基于 Docker 开发 NodeJS 应用
- 使用Docker来加速构建Android应用的基本部署思路解析
- 在Docker上部署Python的Flask框架的教程
- 在Docker上开始部署Python应用的教程
- 详解在Python和IPython中使用Docker
- python脚本监控docker容器