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. html中target的用法

  2. codeforces 611C

    题意: 给你一个矩阵,矩阵里有" . "和" # "," . "表示空的," # "表示禁止的. 多米诺骨牌将占据正好有 ...

  3. GitHub笔记---邮箱访问错误

    GitHub地址太长,所以需要一个变量来保存 把远程仓库赋值给一个变量,以后就用就这变量代表这个地址 GitHub推送push 推送过程中发生一个小插曲,出现了错误,错误提示我复制过来吧 remote ...

  4. 如何使用go打出hell word

    今天给大家带来一篇如何使用go打出hell word(手动滑稽) 关于go介绍的话,我就不多说了,在百度上一搜一大堆, 要使用的软件Visual Studio Code(VScode) 下载go的地址 ...

  5. 449B

    B. Chtholly's request time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  6. python之类的相关名词解释

    变量:在类里面定义的变量,不必实例化即可调用 实例变量:在类里面定义的变量,必须实例化之后才可以调用 比如: 属性方法:调用时看起来像是一个变量,方法没有入参,可以变成一个属性方法 在方法上添加@pr ...

  7. [CQOI2014]通配符匹配

    Description 几乎所有操作系统的命令行界面(CLI)中都支持文件名的通配符匹配以方便用户.最常见的通配符有两个,一个是星号(""'),可以匹配0个及以上的任意字符:另一个 ...

  8. Ubuntu 安装 node

    ubuntu安装node和npm的命令行命令: sudo apt install nodejs-legacy sudo apt install npm 最新版本安装方法 1.安装npm sudo ap ...

  9. Magento 缓存机制简析

    在知道缓存机制前,首先需要知道,Magento的路由机制,这边就不做赘述了,百度一大堆. 下面一个简单的缓存生效流程: A:首先在页面开始时,Magento在app\code\core\Mage\Co ...

  10. HAL之串口

    在STM32cubeMX中 1 外设功能打开 2 GPIO对应管脚的串口功能打开 3 对应GPIO引脚的配置 4串口的配置,中断的设置 在MDK中 5.1 串口初始化MX_USART1_UART_In ...