我有
- 分叉了planetaryDocs專案(一個示例服務器常駐Blazor Web 應用程式),
- 使用 Visual Studio 2022 創建 docker 容器
- 運行那個 docker 容器(通過 Visual Studio)和
并且 Visual Studio 會彈出一個指向 Web 服務器的瀏覽器,它似乎作業正常。
當我這樣做時,docker image ls我看到了planetarydocs 影像。
我想試驗 docker run 命令列。我怎么做?我停止了 Visual Studio docker 容器并
docker.exe run planetarydocs -p 9090:80
這不起作用。
我將瀏覽器指向 http://localhost:9090,瀏覽器顯示“無法訪問此頁面”。
我究竟做錯了什么?
謝謝!
這是使用上述 docker 命令顯示的內容:
{"EventId":35,"LogLevel":"Warning","Category":"Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager","Message":"No XML encryptor configured. Key {3df3c08f-884d-49fe-a4f8-163ea6058090} may be persisted to storage in unencrypted form.","State":{"Message":"No XML encryptor configured. Key {3df3c08f-884d-49fe-a4f8-163ea6058090} may be persisted to storage in unencrypted form.","KeyId":"3df3c08f-884d-49fe-a4f8-163ea6058090","{OriginalFormat}":"No XML encryptor configured. Key {KeyId:B} may be persisted to storage in unencrypted form."}}
{"EventId":14,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://[::]:80","State":{"Message":"Now listening on: http://[::]:80","address":"http://[::]:80","{OriginalFormat}":"Now listening on: {address}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Application started. Press Ctrl\u002BC to shut down.","State":{"Message":"Application started. Press Ctrl\u002BC to shut down.","{OriginalFormat}":"Application started. Press Ctrl\u002BC to shut down."}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Hosting environment: Production","State":{"Message":"Hosting environment: Production","envName":"Production","{OriginalFormat}":"Hosting environment: {envName}"}}
{"EventId":0,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Content root path: /app","State":{"Message":"Content root path: /app","contentRoot":"/app","{OriginalFormat}":"Content root path: {contentRoot}"}}
2021 年 12 月 31 日星期五更新
好吧,我很尷尬:這行得通!
docker.exe run -p 9090:80 planetarydocs
如果docker run給我一個提示,我的開關訂購錯誤,那就太好了……
有人可以指出我在launchsettings.json中描述docker的這種有趣語法的檔案嗎?
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"publishAllPorts": true,
"useSSL": true
}
我一直在查看 appsettings.json 和 launchsettings.json 認為 docker 的埠應該在那里,但他們沒有。
ServicePort和ServiceHost和scheme定義在哪里?這與 Visual Studio 每次從 docker 容器啟動應用程式時都使用新埠這一事實有關嗎?為什么這樣做?
由于埠 80 有效,不應該在這些組態檔中的某處定義埠 80 嗎?
誰使用此啟動設定組態檔?只有 Visual Studio?如果我們從命令列運行 docker,我想我們會忽略組態檔嗎?
uj5u.com熱心網友回復:
你的運行命令是錯誤的。Docker 的任何引數都需要放在映像名稱之前。影像名稱后的任何引數都會覆寫影像中的任何 CMD 定義。
所以代替
docker.exe run planetarydocs -p 9090:80
你應該做
docker.exe run -p 9090:80 planetarydocs
uj5u.com熱心網友回復:
從您指向的存盤庫中,該應用程式似乎使用埠 8081。
PlanetaryDocs/appsettings.json
"EndPoint": "https://localhost:8081/",
如果您沒有更改它,請改用該埠嘗試此命令
docker.exe run planetarydocs -p 9090:8081
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/400402.html
上一篇:dockercompose無法從谷歌容器注冊表中提取影像
下一篇:沒有起始行:crypto/pem/pem_lib.c:745:Expecting:CERTIFICATEREQUEST
