如何在Docker中共享环境variables
我对docker工人很陌生,我有很多麻烦让它开始。 我正在为Visual Studio 2017做一个asp.net核心1.0.1应用程序用户docker容器工具。我有以下env.file在与这个值的撰写文件相同的根:
REDIS_PORT=6379
和这个docker组成yml:
version: '2' services: haproxy: image: eeacms/haproxy links: - webapplication3 ports: - "80:80" webapplication3: image: webapplication3 enviroment: - REDIS_PORT=${REDIS_PORT} build: context: . dockerfile: Dockerfile links: - redis ports: - "80" redis: image: redis ports: - ${REDIS_PORT}
我想知道我必须从我的Asp.net核心应用程序连接到的Redis端口。 据我所知,唯一的方法是使用envvariables,因为我不想复制粘贴到任何地方的端口我想使用.env文件样式。 无论如何,这不是说:
Unsupported config option for services.webapplication3:'enviroment'
任何想法可能是什么问题?
你在单词environment
错过了一个字母“n”。
您需要传递env_file选项:
version: '2' services: haproxy: image: eeacms/haproxy links: - webapplication3 ports: - "80:80" webapplication3: image: webapplication3 env_file: - env.file environment: - REDIS_PORT=${REDIS_PORT} build: context: . dockerfile: Dockerfile links: - redis ports: - "80" redis: image: redis env_file: - env.file ports: - ${REDIS_PORT}
看看https://docs.docker.com/compose/environment-variables/了解更多信息。
- 为什么dockerbuild立我的复制path与临时目录前缀?
- configuration中缺less从VS发布到Ubuntu的Docker?
- 在OSX中的Docker容器中缺lessDotnet Antiforgery DLL
- 如何读取环境variables在ASP.NET核心2.0 + Docker中?
- 基于环境的连接string与ASP NET CORE和Docker支持
- 未能build立:获取https://registry-1.docker.io/v2/microsoft/aspnetcore/manifests/1.1:未经授权:不正确的用户名或密码
- 在Docker中一起安装SQL和一个新的ASP.Net Core项目
- 了解VS2017 webform应用程序的docker-compose
- 不能将中间docker容器文件复制到主机