docker - 如何读取 dockerfile 中的当前 docker 标签?

如何读取dockerfile中当前的docker标签?

Example:
// run in cmd
docker build . -t thisismytag

// docker file
FROM node:14-alpine AS build

RUN echo $TAG // prints thisismytag

最佳答案

您可以将标签作为单独的参数传入

docker build -t thisismytag --build-arg TAG=thisismytag

在 dockerfile 中

FROM node:14-alpine AS build
ARG TAG=unknown
RUN echo $TAG // prints thisismytag

但是,正如评论中所述,图像标签可能会在构建图像后发生变化。这不会反射(reflect)在图像中。

https://stackoverflow.com/questions/63720575/

相关文章:

node.js - 安装react时npm启动问题,如何解决?

java - .rsaEncryptionOAEPSHA256算法在iOS上与Java的兼容性

android - 分享内容 : Permission Denial when using Inte

stripe-payments - Stripe Checkout session 后如何在发票上获

tensorflow - 如何将 tf.data.Dataset 与 kedro 一起使用?

python - 使用最佳学习率导致随机猜测的准确性

c# 9.0 记录 - 反射和通用约束

flutter - 如何在Flutter中实现模糊背景Bottom Modal Sheet?

python - 雪花 Python Okta 连接

r - 如何使用 igraph R 包比较两个图以识别两个图之间相同/不同边的数量