[英]Docker postgres container exits with error code 1 without error message
[英]Why dotnet fsi exits without error message in docker container?
我有一個 Docker 圖像,它可以在我的筆記本電腦上正常工作,並且在 GitHub 操作中作為一個步驟運行時。 但是當我在我的服務器上運行圖像時,它失敗了。
我已經能夠通過這些簡單的步驟重現該問題:
docker run -it --rm mcr.microsoft.com/dotnet/sdk:6.0
dotnet fsi
#r "nuget: Npgsql";;
這在我的筆記本電腦上運行良好。 但在服務器上失敗(沒有錯誤消息。)在服務器上,鍵入#r "nuget: Npgsql"
后,它會在那里停留一分鍾,然后退出 FSI,返回到 bash 提示符。
筆記本電腦:Windows 10,Docker 版本 20.10.11成功
C:\> docker run -it --rm mcr.microsoft.com/dotnet/sdk:6.0
root@5737a66dc73e:/# dotnet fsi
Microsoft (R) F# Interactive version 12.0.0.0 for F# 6.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> #r "nuget: Npgsql";;
[Loading /tmp/nuget/2308--189d6772-0c33-4179-b170-f6bddfd16985/Project.fsproj.fsx]
namespace FSI_0002.Project
> open Npgsql;;
>
服務器:Ubuntu 20.04.3 LTS,Docker 版本 20.10.12(以 root 身份登錄)失敗
root@server021:/# docker run -it --rm mcr.microsoft.com/dotnet/sdk:6.0
root@0ff2e4143ca0:/# dotnet fsi
Microsoft (R) F# Interactive version 12.0.0.0 for F# 6.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> #r "nuget: Npgsql";;
root@0ff2e4143ca0:/#
編輯 1
服務器托管容器的 F# Interactive 是否具有對 nuget.org 的 HTTPS GET 訪問權限? 是的。
root@server021:~# docker run -it --rm mcr.microsoft.com/dotnet/sdk:6.0
root@e0a4050b9505:/# dotnet fsi
Microsoft (R) F# Interactive version 12.0.0.0 for F# 6.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> let client = new System.Net.Http.HttpClient();;
val client: System.Net.Http.HttpClient
> let response = client.GetAsync("https://www.nuget.org/packages/Npgsql/atom.xml").Result.Content.ReadAsStringAsync().Result;;
val response: string =
"<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www"+[64481 chars]
>
I was also able to get valid responses from https://www.nuget.org/api/v2/package/Npgsql/6.0.2
and https://globalcdn.nuget.org/packages/npgsql.6.0.2.nupkg
使用相同的技術。
編輯 2
可以使用較舊的WebClient
API 而不是較新的HttpClient
重現問題嗎? 不,WebClient 在 F# Interactive 中也沒有連接問題。
root@server021:~# docker run -it --rm mcr.microsoft.com/dotnet/sdk:6.0
root@f8a9b61e2991:/# dotnet fsi
Microsoft (R) F# Interactive version 12.0.0.0 for F# 6.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> let client = new System.Net.WebClient();;
let client = new System.Net.WebClient();;
-----------------^^^^^^^^^^^^^^^^^^^^
/stdin(1,18): warning FS0044: This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.
val client: System.Net.WebClient = System.Net.WebClient
> client.DownloadFile("https://globalcdn.nuget.org/packages/npgsql.6.0.2.nupkg", "npgsql.6.0.2.nupkg");;
val it: unit = ()
> System.IO.FileInfo("./npgsql.6.0.2.nupkg").Length;;
val it: int64 = 2359331L
>
任何想法為什么圖像在我的服務器上表現不同?
服務器內存不足 memory 。
有一條服務器端日志消息指出,“超出 memory:已終止進程...(dotnet)...”
我最初將服務器配置為 512MB RAM(大概是為了省錢)。將其增加到 2GB 后,我的 FSX 腳本成功運行。
感謝幫助我排除其他可能性的評論者!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.