在Docker容器中访问标签作为环境变量 [英] Accessing tag as an environment variable inside a Docker container
问题描述
我希望能够访问用于在该容器内构建泊坞窗容器的标签/修订版。有没有一种简单的方法在构建过程中将标记/修订表达为环境变量?
例如,我希望在容器中运行的API知道它的当前状态修订。如果没有docker,我通常会使用git将修订版写入API可以访问的文件中,但这似乎不是Docker的方式。
现在可以使用docker构建参数。
$ b
https://docs.docker.com/engine/reference/commandline/build/
docker build --build-arg TAG = v0.0.1。
I'd like to be able to access the tag/revision used to build a docker container from within that container. Is there a simple way to surface the tag/revision during the build as an environmental variable?
For example, I would like an API running inside a container to know its current revision. Without docker I would normally use git to write the revision to the a file that the API can access, but this doesn't seem to be the "Docker way".
This is now possible with docker build arguments.
https://docs.docker.com/engine/reference/commandline/build/
docker build --build-arg TAG=v0.0.1 .
这篇关于在Docker容器中访问标签作为环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!