【问题标题】:Docker .Net Core app on Ubuntu not opening in localhost:8000Ubuntu 上的 Docker .Net Core 应用程序未在 localhost:8000 中打开
【发布时间】:2017-06-16 01:05:41
【问题描述】:

我在 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

【问题讨论】:

  • 请问可以添加撰写文件吗?
  • @johnharris85 感谢您的评论。我添加了整个回购,所以你可以看看它。我很想得到它,这样我就可以用 localhost 在浏览器中打开它!
  • 试试localhost:5000
  • @johnharris85 亲爱的,成功了!谢谢!!

标签: .net bash ubuntu docker docker-compose


【解决方案1】:

docker-compose up 运行时,它会默认查找两个文件,docker-compose.ymldocker-compose.override.yml。存储库中的 docker-compose.yml 没有指定任何映射,而是主机上的 docker-compose.override.yml has a mapping of 5000 到 UI 容器中的 80。不确定您的同事在8080 上的用户界面如何,除非他们映射了不同的东西。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-02
    相关资源
    最近更新 更多