简体   繁体   English

docker 容器中的 Running.env 文件

[英]Running .env files within a docker container

I have been struggling to add env variables into my container for the past 3 hrs:( I have looked through the docker run docs but haven't managed to get it to work.在过去的 3 个小时里,我一直在努力将 env 变量添加到我的容器中:(我查看了docker 运行文档,但没有设法让它工作。

I have built my image using docker build -t sellers_json_analysis.我使用docker build -t sellers_json_analysis. which works fine.效果很好。

I then go to run it with: docker run -d --env-file./env sellers_json_analysis然后我用 go 运行它: docker run -d --env-file./env sellers_json_analysis

As per the docs: $ docker run --env-file./env.list ubuntu bash but I get the following error:根据文档: $ docker run --env-file./env.list ubuntu bash但我收到以下错误:

docker: open ./env: no such file or directory.

The .env file is in my root directory .env文件在我的根目录中

But when running docker run --help I am unable to find anything about env variables, but it doesn't provide the following:但是在运行docker run --help时,我找不到任何关于环境变量的信息,但它没有提供以下内容:

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

So not sure I am placing things incorrectly.所以不确定我放错了东西。 I could add my variables into the dockerfile but I want to keep it as a public repo as it's a project I would like to display.我可以将我的变量添加到 dockerfile 但我想将其保留为公共回购,因为它是我想展示的项目。

Your problem is wrong path, either use .env or ./.env , when you use ./env it mean a file named env in current directory您的问题是路径错误,使用.env./.env ,当您使用./env时,这意味着当前目录中有一个名为env的文件

docker run -d --env-file .env sellers_json_analysis

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM