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 ...
随机推荐
- 记一次OutOfMemory定位过程-续
在前文<记一次OutOfMemory定位过程>完成时最终也没有定位到ECS 中JVM Heap size无法控制的原因,今天再次尝试终于有了一些线索,翻查了ECS的部署脚本发现了memor ...
- E20170415-ms
opaque adj 不透明的 n 不透明 adapter n 配适器
- JZOJ4307. 【NOIP2015模拟11.3晚】喝喝喝
Description
- shell Syntax error: Bad fd number 错误解决
最近在玩spark , 需要看一下python的spark lib 是怎么加入环境变量的. 执行: sh -x bin/pyspark 报错 + dirname bin/pyspark + cd bi ...
- 洛谷 P2672 推销员
题目传送门 解题思路: 我们会发现本题有一个特性,就是如果我们走到一个更远的地方,那么近的地方距离原点的距离我们可以忽略. 本题要求最大的疲劳值,所以我们需要排序,第一个想到堆,反正我是先想到堆. 然 ...
- hdu1879 继续畅通工程 基础最小生成树
#include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> u ...
- 洛谷1387(基础二维dp)
题目很简单,数据也很小,但是思路不妨借鉴:dp[i][j]代表以(i,j)为右下角的最长正方形边长. 类比一维里面设“以XX为结尾的最XXX(所求)”. 另外define不要乱用!尤其这种min套mi ...
- 不通过ecplise,只通过文件目录 创建最简单的JSP文件
手动创建最简单的JSP 文件 1.在Tomcat 6.0的安装目录的webapps目录下新建一个目录,起名叫myapp. 2.在myapp目录下新建一个目录WEB-INF,注意,目录名称是区分大小 ...
- 数据库sql 使用 lag 和OVER 函数和 like 使用 小技巧
1. sample 1: Lag()就是取当前顺序的上一行记录.结合over就是分组统计数据的.Lag()函数,就是去上N行的字段的数据. SQL> select * from x; A---- ...
- P3717 [AHOI2017初中组]cover
题目背景 以下为不影响题意的简化版题目. 题目描述 一个n*n的网格图上有m个探测器,每个探测器有个探测半径r,问这n*n个点中有多少个点能被探测到. 输入输出格式 输入格式: 第一行3个整数n,m, ...