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. 2.27 MapReduce Shuffle过程如何在Job中进行设置

    一.shuffle过程 总的来说: *分区 partitioner *排序 sort *copy (用户无法干涉) 拷贝 *分组 group 可设置 *压缩 compress *combiner ma ...

  2. hibernate的基础学习--多对多关联

    多对多采用学生老师模型进行测试 学生配置文件: <?xml version="1.0" encoding="utf-8" ?> <!DOCTY ...

  3. Unity3D模型制作规范[转]

    本文提到的所有数字模型制作,全部是用3D MAX建立的模型,即使是不同的驱动引擎,对模型的要求基本是相同的.当一个VR模型制作完成时,它所包含的基本内容包括:场景尺寸.单位,模型归类塌陷.命名.节点编 ...

  4. POJ2533/hdoj1950【DP】

    O(nlog(n))的方法: 定义d[k]:长度为k的上升子序列的最末元素,若有多个长度为k的上升子序列,则记录最小的那个最末元素. d中元素也是单调递增的. #include <iostrea ...

  5. IT兄弟连 Java Web教程 Web开发的相关知识

    Web基本概念 Web,是环球信息网的缩写,也称作“WWW.W3”,英文全称为World Wide Web,中文名成为万维网,常简称为Web.Web分为Web客户端和Web服务器程序.Web可以让We ...

  6. P1229-神秘岛

    神秘岛 描述 Description FireDancer来到一个神秘岛,他要从岛的西头到东头然后在东头的码头离开.可是当他走了一次后,发现这个岛的景色非常的美丽,于是他从东头的传送门传到了西头,换了 ...

  7. .NET CORE之API日志收集

    我们在构建WEBAPI项目时,通常需要构建一个全局的记录API 请求和返回 的功能,在WEBAPI框架下 我们通过自定义一个DelegateHandler来实现这个功能, 在.NET CORE框架下已 ...

  8. hdu2489 Minimal Ratio Tree dfs枚举组合情况+最小生成树

    #include <stdio.h> #include <set> #include <string.h> #include <algorithm> u ...

  9. iOS NSUserDefaults [setValue:forKey:] [setObject:forKey:] <Objc> setValue(_,forKey:) set(_,forKey) <Swift 3>

    前者其实是NSObject都可以调用的KVC方法,后者才是NSUserDefaults的实例方法: 这里参数的类型是nullable id,但是我建议你在传null的时候慎重考虑,否则你的应用就可能面 ...

  10. 一些CSS的备忘

    text-transform 文本转换 属性值是 none表示没有 不转换 同时也是默认的 capitalize 表示首字母大写 uppercase全部转换为大写 lowercase全部转为小写 te ...