【发布时间】:2018-07-31 09:21:52
【问题描述】:
我的 docker-compose.yml 如下所示。
version: '3.4'
services:
identity.api:
image: panda/identity.api
build:
context: .
dockerfile: Services/Identity/PandaMarket.Identity.Api/Dockerfile
ports:
- "5000:80"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionString=Server=sql.server;Database=PandaMarket.Identity;User Id=sa;Password=Password#123
当我执行 docker-compose build 或 docker-compose up
我检查docker inspect panda/identity.api,我找不到ASPNETCORE_ENVIRONMENT & ConnectionString 出现。
当我表演时
docker inspect -f '{{range $index, $value := .Config.Env}} {{$value}} {{end}}' panda/identity.api
我只能看到这些变量
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin ASPNETCORE_URLS=http://+:80 DOTNET_RUNNING_IN_CONTAINER=true ASPNETCORE_VERSION=2.1.2
我的问题是环境如何反映在图像中?
【问题讨论】:
-
这是环境变量,将被添加到您正在运行的容器中。它们在图像中不为人所知。当您检查容器而不是图像时,您会看到它们。如果你想把这个环境变量放在你的镜像中,你需要编写一个 Dockerfile 并添加 ENV 语句。
标签: docker docker-compose