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 ...
随机推荐
- gdb调试带参数的程序 (转载)
转自:http://www.cnblogs.com/rosesmall/archive/2012/04/10/2440514.html 一般来说GDB主要调试的是C/C++的程序.要调试C/C++的程 ...
- PHP empty()函数使用需要注意
在 PHP 5.5 之前,empty() 仅支持变量:任何其他东西将会导致一个解析错误.换言之,下列代码不会生效: empty(trim($name)). 作为替代,应该使用trim($name) = ...
- hdoj5813【构造】
2016 Multi-University Training Contest 7 05 真的真的好菜哇... 思路: 暴力. 我对那些到达目的地少的点做硬性规定就是去比他要到达目的地更少的点,这样一来 ...
- 360安全中心:WannaCry勒索软件威胁形势分析
猫宁!!! 参考链接:http://zt.360.cn/1101061855.php?dtid=1101062360&did=210646167 这不是全文,而是重点摘要部分. 2017年5月 ...
- vue的方法和计算属性的区别
首先看看 methods 方法 // html <div id="vue"> <button v-on:click = "a++">ad ...
- java实训 :异常(try-catch执行顺序与自定义异常)
关键字: try:执行可能产生异常的代码 catch:捕获异常 finally:无论是否发生异常代码总能执行 throws:声明方法可能要抛出的各种异常 throw:手动抛出自定义异常 用 try-c ...
- 给Clouderamanager集群里安装可视化分析利器工具Hue步骤(图文详解)
扩展博客 以下,是我在手动的CDH版本,安装Hue. CDH版本大数据集群下搭建Hue(hadoop-2.6.0-cdh5.5.4.gz + hue-3.9.0-cdh5.5.4.tar.gz)(博主 ...
- 跟我一起玩Win32开发(23):渐变颜色填充
GradientFill函数可以对特定的矩形区域或者三角形区域进行渐变颜色的填充.我们先来看看GradientFill函数到底长得什么样子,帅不帅. BOOL GradientFill( _In_ ...
- 跟我一起玩Win32开发(3):窗口的重绘
c可以编译#include <Windows.h> //先声明一下消息处理函数 LRESULT CALLBACK MyWindowProc(HWND hwnd, UINT msg, WPA ...
- MySQL FailOver(官方自带,free)
为什么 传统复制和GTIDs切换的缺点 当replication故障出现之后,最头疼是replication架构的调整 一旦master down了,就需要配置某一台slave作为master sla ...