dockerfile note
reference

summary

  1. 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.

  2. usage
    the docker build command 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 .

  3. format
    a. INSTRUCTION is not case-sensitive but convention is UPPERCASE. e.g: FROM nginx:1.13
    b. must start with FROM.

    c. docker treat lines begin with # as a comment.

  4. 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=value then the next line is FROM nginx:1.13

    b. can't repeat

  5. escape
    in linux default is \, " ` " in windows

  6. variable replacement
    ${variable:-word} indicates that if variable is set then the result will be that value. If variable is not set then word will be the result.
    ${variable:+word} indicates that if variable is set then word will be the result, otherwise the result is the empty string.

  7. .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 it

  8. FROM
    The tag or digest values are optional. If you omit either of them, the builder assumes a latest tag by default
    FROM buildpack-deps:jessie

  9. RUN
    RUN /bin/bash -c 'source $HOME/.bashrc; \ echo $HOME'
    equivalent to following
    RUN /bin/bash -c 'source $HOME/.bashrc; echo $HOME'

  10. 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 -

  11. 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 name

  12. EXPOSE
    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_name

  13. ENV
    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 ti ENV myName = John Doe

  14. ADD
    The ADD instruction copies new files, directories or remote file URLs from and adds them to the filesystem of the image at the path

  15. COPY
    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 ADD

  16. VOLUME
    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 as VOLUME /var/log orVOLUME /var/log/var/db

  17. WORKDIR
    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的更多相关文章

  1. Dockerize PostgreSQL

    Dockerize PostgreSQL Installing PostgreSQL on Docker Assuming there is no Docker image that suits yo ...

  2. 分析Mysql 5.6的Dockerfile

    Docker官方的Mysql镜像的Dockerfile托管在Github上,地址如下: https://github.com/docker-library/mysql/tree/5836bc9af9d ...

  3. docker note

    docker --bip="10.1.42.1/16" -d 挂载宿主机目录 Docker支持挂载宿主机目录,支持宿主机目录和容器之间文件目录进行映射,彼此共享: docker r ...

  4. Dockerfile详解

    Dockerfile详解 利用Dockerfile文件,可以构建docker的image镜像 命令使用 通过-f参数指定Dockerfile路径,进行构建image docker build -f / ...

  5. dockerfile语法

    dockerfiles的指令不区分大小写,但约定为全部大写 dockerfiles支持如下语法命令: 1.FROM <image name> 所有的dockerfile都必须以from命令 ...

  6. Docker教程:镜像构建和自动镜像构建dockerfile

    http://blog.csdn.net/pipisorry/article/details/50805379 Docker透过Dockerfile来记录建立Container映象文件的每一个步骤,可 ...

  7. Dockerfile centos7_php5.6.36

    Dockerfile: FROM centos:7 MAINTAINER www.ctnrs.com RUN yum install epel-release -y && \ yum ...

  8. Images之Dockerfile中的命令2

    COPY COPY has two forms: COPY [--chown=<user>:<group>] <src>... <dest> COPY ...

  9. Images之Dockerfile中的命令1

    Dockerfile reference Docker can build images automatically by reading the instructions from a Docker ...

随机推荐

  1. PHP empty()函数使用需要注意

    在 PHP 5.5 之前,empty() 仅支持变量:任何其他东西将会导致一个解析错误.换言之,下列代码不会生效: empty(trim($name)). 作为替代,应该使用trim($name) = ...

  2. POJ - 1661 - Help Jimmy - 简单dp

    http://poj.org/problem?id=1661 一般化处理,把一开始的落地和大地都视作平台,设计平台类的属性.dp的时候显然是从上往下dp的,而且要小心Jimmy不能够穿过平台,也就是从 ...

  3. CSA Round #50 (Div. 2 only) Min Swaps(模拟)

    传送门 题意 给出一个排列,定义\(value为\sum_{i=1}^{n-1}abs(f[i+1]-f[i])\) \(swap(a[i],a[j])(i≠j)为一次交换\),询问最少的交换次数使得 ...

  4. python matplotlib相关 dateutil

    dateutil:   easy_install python_dateutil pyparsing: easy_install pyparsing

  5. Centos 搭建Mysql-Proxy 读写分离

    Mysql 读写分离 主:192.168.153.130 从:193.168.153.131 Mysql-Proxy:193.168.153.132 这里省略mysql主从同步,如果有需要,请查看:M ...

  6. C++面向对象程序设计举例

    [例8.1]最简单的例子. #include <iostream> using namespace std; class Time //定义Time类 { public : //数据成员为 ...

  7. 第05课 Linux命令初探(一)

    该篇为第一部分,主要介绍的Linux指令有: mkdir.cd.ls.rm.touch.vi/vim.echo.cat.cp.mv.pwd.rm.rmdir 1.创建一个目录/data 提示:Wind ...

  8. java自带线程池

    1. newSingleThreadExecutor 创建一个单线程的线程池.这个线程池只有一个线程在工作,也就是相当于单线程串行执行所有任务.如果这个唯一的线程因为异常结束,那么会有一个新的线程来替 ...

  9. 129 Sum Root to Leaf Numbers 求根叶数字总和

    给定一个只包含 0-9 数字的二叉树,每个根到叶的路径可以代表一个数字.例如,从根到叶路径 1->2->3则代表数字 123.查找所有根到叶数字的总和.例如,    1   / \  2  ...

  10. Bootstrap中的datetimepicker浅谈

    从古至今,人们都习惯用某个时间来标记某个事件的发生.我们在写管理后台的时候,重中之中也是这个时间的设置.在问题出现的时候,我们是查看日志的时候,就可以根据这个时间段来查找这个问题出现点. 在使用时间控 ...