Docker 环境变量 + Heroku; Heroku 需要 ENV 而本地构建需要 ARG

标签 docker heroku

我对 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/

相关文章:

c# - 在 C# dockerfile 中运行可执行文件

ruby-on-rails - Heroku Rails PostgreSQL 安装错误

mongodb - flask mongoengine 通过 uri 连接

heroku - Heroku 中 Redis Cloud 中的 BROKER_URL

heroku - 'git push heroku master' 命令返回 'fatal: Could not read from remote repository'

javascript - 将 NodeJS 应用程序上传到 Heroku 时缩小 JS 和 CSS 的好方法是什么

docker - Mesos和Marathon中的Docker容器磁盘大小

php - 使用 nginx-proxy 找不到 nginx 返回文件并且不加载静态文件

docker - curl:(7)无法连接到本地主机端口10001:连接被拒绝DOCKER

git - 使用 Docker 在生产中部署 Go 服务