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. 算法练习--LeetCode--17. Letter Combinations of a Phone Number

    Letter Combinations of a Phone NumberMedium Given a string containing digits from 2-9 inclusive, ret ...

  2. 纳尼,Java 存在内存泄泄泄泄泄泄漏吗?

    01. 怎么回事? 纳尼,Java 不是自动管理内存吗?怎么可能会出现内存泄泄泄泄泄泄漏! Java 最牛逼的一个特性就是垃圾回收机制,不用像 C++ 需要手动管理内存,所以作为 Java 程序员很幸 ...

  3. StructLayoutLayout 属性无法通过GetCustomAttributes 或者 Attributes获得

    http://stackoverflow.com/questions/17684664/retrieve-the-structlayout-attribute-of-a-struct 这是一个type ...

  4. 图论之最短路算法之SPFA算法

    SPFA(Shortest Path Faster Algorithm)算法,是一种求最短路的算法. SPFA的思路及写法和BFS有相同的地方,我就举一道例题(洛谷--P3371 [模板]单源最短路径 ...

  5. Luogu P3694 邦邦的大合唱站队 【状压dp】By cellur925

    题目传送门 最开始学状压的时候...学长就讲的是这个题.当时对于刚好像明白互不侵犯和炮兵阵地的我来说好像在听天书.......因为我当时心里想,这又不是什么棋盘,咋状压啊?!后来发现这样的状压多了去了 ...

  6. Qt之对话框QDialog

    这一节主要讲述对话框类,先讲述两种不同类型的对话框,再介绍Qt提供的几个标准对话框.对应本节的内容,可以在帮助索引中查看 QDialog 和 Dialog Windows 关键字. 一.模态和非模态对 ...

  7. Educational Codeforces Round 46 (Rated for Div. 2) E. We Need More Bosses

    Bryce1010模板 http://codeforces.com/contest/1000/problem/E 题意: 给一个无向图,求图的最长直径. 思路:对无向图缩点以后,求图的最长直径 #in ...

  8. 1-20StringBuffer简介

    StringBuffer是一个字符串缓冲区,如果需要频繁的对字符串进行拼接时,建议使用StringBuffer. 工作原理 StringBuffer的底层是char数组,如果没有明确设定,则系统会默认 ...

  9. 【转】10种简单的Java性能优化

    10种简单的Java性能优化 2015/06/23 | 分类: 基础技术 | 14 条评论 | 标签: 性能优化 分享到: 本文由 ImportNew - 一直在路上 翻译自 jaxenter.欢迎加 ...

  10. webuploader上传工具

    http://fex.baidu.com/webuploader/getting-started.html#显示用户选择 Html部分 首先准备dom结构,包含存放文件信息的容器.选择按钮和上传按钮三 ...