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 ...
随机推荐
- ORACLE PL/SQL 实例精解之第四章 条件控制:if 语句
4.1 IF 语句 IF语句两种形式:IF-THEN IF-THEN-ELSE 使用IF-THEN,可以指定需要执行的一组动作. IF-THEN-ELSE语句指定两组动作 1. IF-THEN TRU ...
- 深度解密Go语言之 map
目录 什么是 map 为什么要用 map map 的底层如何实现 map 内存模型 创建 map 哈希函数 key 定位过程 map 的两种 get 操作 如何进行扩容 map 的遍历 map 的赋值 ...
- 704. Binary Search
Given a sorted (in ascending order) integer array nums of n elements and a target value, write a fun ...
- lightoj1169【DP】
题意(来自大哥): 有两栋楼,左边一栋,右边一栋,层数从1-n,地面的标号为0,每一层有一个水果.有一只猴子在地面上,他现在要上到n层去,在第i层会吃掉水果花费一定时间. 猴子有两种方式从第i层到i+ ...
- hdoj5698
果然以前不想搞的东西,今天他妈全来了,我要爆炸,除了说操....真是欲哭无泪啊..... //这道题目卡在逆元了.... //利用逆元计算1/(n!(m-n)!) //对于正整数a,m如果有ax≡1( ...
- bzoj 1207: [HNOI2004]打鼹鼠【dp】
跟简单的dp,设f[i]表示前i只最多打几只,因为起点不确定,所以f[i]可以从任意abs(x[i]-x[j])+abs(y[i]-y[j])<=abs(time[i]-time[j])的j&l ...
- spring @InitBinder
/** * 将字符串日期转化为Date类型 * @param binder */ @InitBinder protected void initBinder(WebDataBinder binder) ...
- Hdu 5458 Stability (LCA + 并查集 + 树状数组 + 缩点)
题目链接: Hdu 5458 Stability 题目描述: 给出一个还有环和重边的图G,对图G有两种操作: 1 u v, 删除u与v之间的一天边 (保证这个边一定存在) 2 u v, 查询u到v的路 ...
- curry柯里化函数实现
curry柯里化函数实现 参考文章: 一行写出javascript函数式编程中的curry 感谢作者分享 第一步: 缓存原始函数的参数个数 function curry(fn) { var limit ...
- Ubuntu 安装 node
ubuntu安装node和npm的命令行命令: sudo apt install nodejs-legacy sudo apt install npm 最新版本安装方法 1.安装npm sudo ap ...