Learn docker and linux commands from cvat's Dockerfile

  1. ENV, ARG respectively specify the variables in the image construction process and in the container
ARG USER  # USER变脸以及下面的DJANGO_CONFIGURATION均在构建镜像过程中有效,构建完成后以及容器内均无效
ARG DJANGO_CONFIGURATION
ENV DJANGO_CONFIGURATION=${DJANGO_CONFIGURATION}  # 在镜像构建后,容器启动后依然有效,可覆盖
  1. wget: linux download tool, -q does not output information, -O writes the document to file
    echo: output string to the screen
    tee: saves the output to the specified file
    DEBIAN_FORNTEND: environment variable, tells the operating system how to obtain user input, set to ' Noninteractive' means that no user input is required. The non-interactive mode is very fast when building the image, but do not cover it with environment variables to avoid affecting the interaction.
ARG WITH_TESTS
RUN if [ "$WITH_TESTS" = "yes" ]; then \
        wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \  # 下载谷歌软件公钥,用于验证之后的软件
        echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list && \  # tee将输出结果保存至apt源
        wget -qO- https://deb.nodesource.com/setup_9.x | bash - && \  # 下载nodejs
        apt-get update && \
        DEBIAN_FRONTEND=noninteractive apt-get install -yq \  # 非交互模式安装
            google-chrome-stable \
            nodejs && \
        rm -rf /var/lib/apt/lists/*; \
        mkdir tests && cd tests && npm install \
            eslint \
            eslint-detailed-reporter \
            karma \
            karma-chrome-launcher \
            karma-coveralls \
            karma-coverage \
            karma-junit-reporter \
            karma-qunit \
            qunit; \
        echo "export PATH=~/tests/node_modules/.bin:${PATH}" >> ~/.bashrc; \
    fi

Guess you like

Origin blog.csdn.net/JosephThatwho/article/details/104251252