docker - 如何正确编写 docker-compose 文件
问题描述
我创建了 asp.net 核心 MVC 应用程序。配置自签名证书以使用 https 连接并使用此命令在 docker 容器中运行它
docker run --rm -it -p 5000:80 -p 5001:443 -e ASPNETCORE_URLS="https://+;http://+" -e ASPNETCORE_HTTPS_PORT=5001 -e ASPNETCORE_Kestrel__Certificates__Default__Password="password" -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/identitycert.pfx -v ${HOME}/.aspnet/https:/https/ kirillbasic/identityserver
我可以轻松连接到我的本地主机。但后来我尝试使用看起来像这样的 docker-compose.yaml 文件
services:
identityserver:
image: kirillbasic/identityserver:test
ports:
- "4999:80"
- "5000:433"
environment:
ASPNETCORE_URLS: https://+;http://+
ASPNETCORE_HTTPS_PORT: 5000
ASPNETCORE_Kestrel__Certificates__Default__Password: password
ASPNETCORE_Kestrel__Certificates__Default__Path: /https/identitycert.pfx
volumes: ["${HOME}/.aspnet/https:/https/"]
我得到“安全连接失败”。我尝试了不同的打字方式:带括号和不带括号,但没有任何帮助。有没有人有任何建议为什么会发生,我该如何解决这个问题?
解决方案
由于 3.3 docker-compose 版本文件中的正则表达式字符,您需要用单引号将该变量括起来。你能试试这个,看看它是否有效。
version: '3.3'
services:
identityserver:
image: kirillbasic/identityserver
ports:
- '5000:80'
- '5001:443'
environment:
- 'ASPNETCORE_URLS=https://+;http://+'
- ASPNETCORE_HTTPS_PORT=5001
- ASPNETCORE_Kestrel__Certificates__Default__Password=password
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/identitycert.pfx
volumes:
- '${HOME}/.aspnet/https:/https/'
推荐阅读
- php - 在远程服务器上运行 laravel
- python - 如何纠正此错误:“换行符”是此函数的无效关键字参数
- c# - 运行项目 netcore 时出现错误 "{"stateMachine":{"<>1__state":-2,"<>t__builder":{"
- matlab - 为什么 Matlab 和 Octave 给出相同方程的结果略有不同?我该如何解决?
- vb.net - VB 加密 XML 错误 0x00 无效
- c# - 使用控制器单击按钮时如何更改 TextArea 文本?
- c# - 如何在 Selenium c# 中断言分配给 ElementId 的值?
- ios - 为什么Eureka TableView的Section header字符串总是显示大写字符???
- android - 我正在使用 Visual Studio Code 开发 react-native。我有以下问题
- javascript - 控制数组中对象的位置