Docker笔记

玖亖伍
2021-06-29 / 1 评论 / 428 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2021年06月29日,已超过1022天没有更新,若内容或图片失效,请留言反馈。

示例

Dockerfile
FROM alpine:latest

ARG TAG=0.0.1
ARG PORT_ARG=3080

RUN apk add --no-cache bash

# 切换默认shell为bash
SHELL ["/bin/bash", "-c"]
RUN echo tag=$TAG
RUN echo port_tag=$PORT_ARG
构建
docker build --no-cache  --progress plain --rm --build-arg TAG=0.0.3 --build-arg PORT_ARG=3000 --tag hello/world:0.0.3 .
运行
docker run hello/world:0.0.3

笔记

  • ARG 用来声明参数,语法为ARG <key>=<default-value>,需要在在FROM之后才会有作用
  • build时, 通过--build-arg的方式传递,语法为--build-arg <key>=<value>, 可以多组

参考

0

评论 (1)

取消
  1. 头像
    Bryan Easter
    MacOS · Google Chrome
    @

    It is with sad regret to inform you that because of the Covid pandemic BestLocalData.com is shutting down.

    We have lost family members and colleagues and have decided to shut down BestLocalData.com

    It was a pleasure serving you all these years. We have made all our databases available for $99 (All of it for $99) for those interested.

    Kind Regards,
    BestLocalData.com
    Bryan

    回复