dockerfile note
dockerfile note
reference
summary
defination
docker can build images automatically by reading the instructions from a dockerfile. dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.usage
thedocker buildcommand builds an image from a dockerfile and context. the build's context is the set of files at a specified location PATH or URL. warning: don't use PATH/, because it can transfer the entire contents of your hard drive to the docker daemon.
docker build -f /home/vickey/dockerfile .- format
a. INSTRUCTION is not case-sensitive but convention is UPPERCASE. e.g:FROM nginx:1.13
b. must start withFROM.c. docker treat lines begin with
#as a comment. - parser directive
reference
a. parser directive is not case-sentive but convention is lowercase and must at the first line of dockerfile e.g:# directive=valuethen the next line isFROM nginx:1.13b. can't repeat
escape
in linux default is\, " ` " in windowsvariable replacement
${variable:-word} indicates that ifvariableis set then the result will be that value. Ifvariableis not set thenwordwill be the result.
${variable:+word} indicates that ifvariableis set thenwordwill be the result, otherwise the result is the empty string..dockerignore file
Before the docker CLI sends the context to the docker daemon, it looks for a file named .dockerignore in the root directory of the context. If this file exists, the CLI modifies the context to exclude files and directories that match patterns in itFROM
The tag or digest values are optional. If you omit either of them, the builder assumes a latest tag by default
FROM buildpack-deps:jessieRUN
RUN /bin/bash -c 'source $HOME/.bashrc; \ echo $HOME'
equivalent to following
RUN /bin/bash -c 'source $HOME/.bashrc; echo $HOME'CMD
There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect
CMD echo "This is a test." | wc -LABEL
A LABEL is a key-value pair.
LABEL version="1.0"
To view an image’s labels, use the docker inspect command
docker inspect docker container nameEXPOSE
By default, EXPOSE assumes TCP. You can also specify UDP:
EXPOSE 80/udp
or publish port when run images
docker run -p 80:80/tcp -p 80:80/udp image_nameENV
The entire string after the first space will be treated as the - including whitespace characters. allows for multiple variables to be set at one time
ENV myName John Doe ENV myDog Rex The Dog
equivalent tiENV myName = John DoeADD
TheADDinstruction copies new files, directories or remote file URLs from and adds them to the filesystem of the image at the pathCOPY
The COPY instruction copies new files or directories from<src>and adds them to the filesystem of the container at the path<dest>.
COPY VS ADDVOLUME
The VOLUME instruction creates a mount point with the specified name and marks it as holding externally mounted volumes from native host or other containers. The value can be a JSON array,VOLUME ["/var/log/"], or a plain string with multiple arguments, such asVOLUME /var/logorVOLUME /var/log/var/dbWORKDIR
The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile
WORKDIR /path/to/workdir RUN pwd
dockerfile note的更多相关文章
- Dockerize PostgreSQL
Dockerize PostgreSQL Installing PostgreSQL on Docker Assuming there is no Docker image that suits yo ...
- 分析Mysql 5.6的Dockerfile
Docker官方的Mysql镜像的Dockerfile托管在Github上,地址如下: https://github.com/docker-library/mysql/tree/5836bc9af9d ...
- docker note
docker --bip="10.1.42.1/16" -d 挂载宿主机目录 Docker支持挂载宿主机目录,支持宿主机目录和容器之间文件目录进行映射,彼此共享: docker r ...
- Dockerfile详解
Dockerfile详解 利用Dockerfile文件,可以构建docker的image镜像 命令使用 通过-f参数指定Dockerfile路径,进行构建image docker build -f / ...
- dockerfile语法
dockerfiles的指令不区分大小写,但约定为全部大写 dockerfiles支持如下语法命令: 1.FROM <image name> 所有的dockerfile都必须以from命令 ...
- Docker教程:镜像构建和自动镜像构建dockerfile
http://blog.csdn.net/pipisorry/article/details/50805379 Docker透过Dockerfile来记录建立Container映象文件的每一个步骤,可 ...
- Dockerfile centos7_php5.6.36
Dockerfile: FROM centos:7 MAINTAINER www.ctnrs.com RUN yum install epel-release -y && \ yum ...
- Images之Dockerfile中的命令2
COPY COPY has two forms: COPY [--chown=<user>:<group>] <src>... <dest> COPY ...
- Images之Dockerfile中的命令1
Dockerfile reference Docker can build images automatically by reading the instructions from a Docker ...
随机推荐
- 算法练习--LeetCode--17. Letter Combinations of a Phone Number
Letter Combinations of a Phone NumberMedium Given a string containing digits from 2-9 inclusive, ret ...
- 纳尼,Java 存在内存泄泄泄泄泄泄漏吗?
01. 怎么回事? 纳尼,Java 不是自动管理内存吗?怎么可能会出现内存泄泄泄泄泄泄漏! Java 最牛逼的一个特性就是垃圾回收机制,不用像 C++ 需要手动管理内存,所以作为 Java 程序员很幸 ...
- StructLayoutLayout 属性无法通过GetCustomAttributes 或者 Attributes获得
http://stackoverflow.com/questions/17684664/retrieve-the-structlayout-attribute-of-a-struct 这是一个type ...
- 图论之最短路算法之SPFA算法
SPFA(Shortest Path Faster Algorithm)算法,是一种求最短路的算法. SPFA的思路及写法和BFS有相同的地方,我就举一道例题(洛谷--P3371 [模板]单源最短路径 ...
- Luogu P3694 邦邦的大合唱站队 【状压dp】By cellur925
题目传送门 最开始学状压的时候...学长就讲的是这个题.当时对于刚好像明白互不侵犯和炮兵阵地的我来说好像在听天书.......因为我当时心里想,这又不是什么棋盘,咋状压啊?!后来发现这样的状压多了去了 ...
- Qt之对话框QDialog
这一节主要讲述对话框类,先讲述两种不同类型的对话框,再介绍Qt提供的几个标准对话框.对应本节的内容,可以在帮助索引中查看 QDialog 和 Dialog Windows 关键字. 一.模态和非模态对 ...
- Educational Codeforces Round 46 (Rated for Div. 2) E. We Need More Bosses
Bryce1010模板 http://codeforces.com/contest/1000/problem/E 题意: 给一个无向图,求图的最长直径. 思路:对无向图缩点以后,求图的最长直径 #in ...
- 1-20StringBuffer简介
StringBuffer是一个字符串缓冲区,如果需要频繁的对字符串进行拼接时,建议使用StringBuffer. 工作原理 StringBuffer的底层是char数组,如果没有明确设定,则系统会默认 ...
- 【转】10种简单的Java性能优化
10种简单的Java性能优化 2015/06/23 | 分类: 基础技术 | 14 条评论 | 标签: 性能优化 分享到: 本文由 ImportNew - 一直在路上 翻译自 jaxenter.欢迎加 ...
- webuploader上传工具
http://fex.baidu.com/webuploader/getting-started.html#显示用户选择 Html部分 首先准备dom结构,包含存放文件信息的容器.选择按钮和上传按钮三 ...