我正在使用 Ubuntu 16.04,我在 Windows 上有一个带有 .Net Core 的 docker 应用程序,并试图让它在 Ubuntu 上运行。我有 docker 和 .Net Core 运行没有错误。
当我运行“sudo docker-compose up”时,它会运行服务器并监听“http://+:80”。但我无法在浏览器中打开它。在 Windows 上,我正在使用的每个人都可以在 localhost:8000 上加载它。
当我运行 docker-compose 这就是我得到的:
sudo docker-compose up
Starting webui
Starting projects_api
Starting profile_api
Starting identity_api
Attaching to projects_api, profile_api, webui, identity_api
profile_api | Hosting environment: Development
profile_api | Content root path: /app
projects_api | Hosting environment: Development
profile_api | Now listening on: http://+:80
projects_api | Content root path: /app
profile_api | Application started. Press Ctrl+C to shut down.
projects_api | Now listening on: http://+:80
projects_api | Application started. Press Ctrl+C to shut down.
identity_api | info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0]
identity_api | User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
identity_api | Hosting environment: Development
identity_api | Content root path: /app
identity_api | Now listening on: http://+:80
identity_api | Application started. Press Ctrl+C to shut down.
现在这些是我尝试过的方法,但是,在 Windows 上,他们使用 Powershell 脚本来 ping 服务器。但我不知道如何将 powershell 转换为 bash。我想也许如果我将它转换为 bash,我可以运行该应用程序。这是应该运行服务器的 powershell 脚本:
param(
[string]$host_url = "http://localhost"
)
@(
"$host_url`:5001/api/health/ping",
"$host_url`:5002/api/health/ping",
"$host_url`:5003/api/health/ping",
"$host_url`:5001/.well-known/openid-configuration"
) |
ForEach-Object { Invoke-WebRequest -Uri $_ } |
Select-Object StatusCode, StatusDescription, Content
最佳答案
当docker-compose up
运行它默认查找两个文件,docker-compose.yml
和 docker-compose.override.yml
. docker-compose.yml
在您的仓库中没有指定任何映射,但 docker-compose.override.yml
has a mapping of 5000
在主机上 80
在 UI 容器中。不确定您的同事在 8080
上的 UI 效果如何尽管除非他们映射了不同的东西。
关于.net - Ubuntu 上的 Docker .Net Core 应用程序未在 localhost :8000 中打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44579254/