我对 Heroku 的 Docker 容器注册表 CLI 的理解是它是 Docker cli 的包装器。
当我在本地构建时,我会使用,例如:docker build -f Dockerfile.example --build-arg SECRET_KEY=abc
.我会设置 ARG SECRET_KEY
在我的 Dockerfile.example 中。
但是,如果我想推送到 heroku 的 docker 容器注册表,我发现我需要声明 ENV SECRET_KEY=abc
在我的 Dockerfile.example 中,然后运行命令 heroku container:push example --recursive
.
为什么会这样?是什么让他们与众不同?硬编码 ENV 不是不好的安全实践吗? Heroku 是否提供了解决此问题的方法?
最佳答案
你可以运行类似的东西
heroku 容器:push web --arg SECRET_KEY=xxxSecret123
这样,您不必直接在 Dockerfile 中提供信息。
关于Docker 环境变量 + Heroku; Heroku 需要 ENV 而本地构建需要 ARG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49476481/