如何从dockerfile中的config_file上传参数到env ?



我有一个包含许多参数的config_file:

FOO=/foo
FOO_1=/bar
...
FOO_100=/opt

我需要在docker容器中设置我的env,它将包含所有这些参数。

我知道——build-arg选项,但我不认为这是一个好主意,因为参数的数量太大了。

所以,我不知道如何正确加载环境变量到容器。

您可以在运行到容器

时使用——env-file参数,

docker run——env-file config。env

检查docker运行选项https://docs.docker.com/engine/reference/commandline/run/#options

替代docker-compose.yml

version: "3.7"
services:
test:
image: test: image
env_file:
- config.env

你可以参考更多的细节https://docs.docker.com/compose/environment-variables/

最新更新