访问Podman容器时出现“Connection reset”问题

问题描述 投票:0回答:1

作为 Podman(非常)初学者,我按照官方 Podman 入门 页面上的说明拉取并运行我选择的容器:

someone@something:~$ podman pull docker.io/kizaing/kavita
[...]
someone@something:~$ podman run -dt -p 8080:80/tcp docker.io/kizaing/kavita

我不只是盲目地(完全)运行命令。我在

podman <subcommand> --help
提供的帮助对话框中了解了每个标志的作用。换句话说,我只知道自己在做什么。也许四分之一知道。

尝试通过 cURL 访问容器时:

someone@something:~$ curl localhost:8080
curl: (56) Recv failure: Connection reset by peer

火狐:

The connection was reset
~~~~~~~~~~~~~~~~~~~~~~~~
The connection to the server was reset while the page was loading.

* The site could be temporarily unavailable or too busy. Try again in a few moments.
* If you are unable to load any pages, check your computer’s network connection.
* If your computer or network is protected by a firewall or proxy, make sure that Firefox Developer Edition is permitted to access the Web.

我在 Firefox 中重新加载了几次页面,重新启动了 Kavita 容器几次,尝试使用我的 Podman 命令中的选项,但仍然一遍又一遍地遇到同样的问题。

SE 上的某个人很可能不可能神奇地猜出是什么导致了我的问题,但我至少正在寻找关于为什么会发生这种情况的建议,以及 potential 解决方案,如果你认为你可能有线索。

再一次,我对这一切都很陌生,并且从未接受过任何与计算机相关的正式培训。

在 5.10.0-21-amd64 内核之上运行 Debian GNU/Linux 11 (bullseye) x86_64。

测试时不运行 VPN 或代理。

编辑:

Podman 可以使用 8080 端口没问题:

someone@something:~$ sudo ss -lnp | grep 8080
tcp   LISTEN 0      4096                                                                   *:8080                   *:*     users:(("exe",pid=35007,fd=12))  

此外,

httpd
使用端口 8080 运行良好,因此再次确认 Podman 可以访问该端口。换句话说,问题是我的 Kavita 容器特有的。 (我在同一个端口上测试 Kavita 之前停止
httpd
,以避免冲突。)

在下面的答案中建议使用

podman logs <container-name>
查看“网络服务器是否在容器中”。但是,我不完全确定要在该日志文件中查找什么,所以这里是:

someone@something:~$ podman logs quizzical_chaum 
[12:28:37 INF] Generating JWT TokenKey for encrypting user sessions...
[Kavita] [2023-04-01 12:28:39.419 +00:00  1] [Information] API.Program Performing backup as migrations are needed. Backup will be kavita.db in temp folder
[Kavita] [2023-04-01 12:28:39.864 +00:00  1] [Error] Microsoft.EntityFrameworkCore.Database.Command Failed executing DbCommand (48ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
SELECT EXISTS (
    SELECT 1
    FROM "ServerSetting" AS "s")
[Kavita] [2023-04-01 12:28:39.904 +00:00  1] [Error] Microsoft.EntityFrameworkCore.Query An exception occurred while iterating over the results of a query for context type 'API.Data.DataContext'.
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: ServerSetting'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: ServerSetting'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
[Kavita] [2023-04-01 12:28:39.914 +00:00  1] [Information] API.Program Database backed up to /kavita/config/temp/migration/vUnknown
[Kavita] [2023-04-01 12:28:39.935 +00:00  1] [Fatal] API.Program Running MigrateSeriesRelationsExport migration - Please be patient, this may take some time. This is not an error
[Kavita] [2023-04-01 12:28:39.935 +00:00  1] [Fatal] API.Program Running MigrateSeriesRelationsExport migration - complete. Nothing to do
[Kavita] [2023-04-01 12:28:57.271 +00:00  1] [Information] API.Services.TaskScheduler Scheduling reoccurring tasks
[Kavita] [2023-04-01 12:28:57.282 +00:00  1] [Debug] API.Services.TaskScheduler Scheduling Scan Library Task for daily
[Kavita] [2023-04-01 12:28:57.489 +00:00  1] [Debug] API.Services.TaskScheduler Scheduling Backup Task for daily
[Kavita] [2023-04-01 12:28:57.496 +00:00  1] [Information] API.Services.TaskScheduler Scheduling Auto-Update tasks
[Kavita] [2023-04-01 12:28:57.501 +00:00  1] [Debug] API.Services.TaskScheduler Scheduling stat collection daily
[Kavita] [2023-04-01 12:28:57.681 +00:00  6] [Information] API.Program Running Migrations
[Kavita] [2023-04-01 12:28:57.800 +00:00  6] [Fatal] API.Program Running MigrateChangeRestrictionRoles migration
[Kavita] [2023-04-01 12:28:57.801 +00:00  6] [Information] API.Program MigrateChangeRestrictionRoles migration complete
[Kavita] [2023-04-01 12:28:57.815 +00:00  6] [Fatal] API.Program Running MigrateSeriesRelationsImport migration - Please be patient, this may take some time. This is not an error
[Kavita] [2023-04-01 12:28:57.816 +00:00  6] [Fatal] API.Program Running MigrateSeriesRelationsImport migration - complete. Nothing to do
[Kavita] [2023-04-01 12:28:57.820 +00:00  6] [Fatal] API.Program Running MigrateUserProgressLibraryId migration - Please be patient, this may take some time. This is not an error
[Kavita] [2023-04-01 12:28:57.826 +00:00  6] [Warning] Microsoft.EntityFrameworkCore.Query The query uses the 'First'/'FirstOrDefault' operator without 'OrderBy' and filter operators. This may lead to unpredictable results.
[Kavita] [2023-04-01 12:28:57.833 +00:00  6] [Fatal] API.Program Running MigrateUserProgressLibraryId migration - complete. Nothing to do
[Kavita] [2023-04-01 12:28:57.905 +00:00  6] [Information] API.Program Running Migrations - done
[Kavita] [2023-04-01 12:28:58.228 +00:00  1] [Information] Microsoft.Hosting.Lifetime Now listening on: http://0.0.0.0:5000
[Kavita] [2023-04-01 12:28:58.229 +00:00  1] [Information] Microsoft.Hosting.Lifetime Now listening on: http://[::]:5000
Kavita - v0.7.1.4
[Kavita] [2023-04-01 12:28:58.231 +00:00  1] [Information] Microsoft.Hosting.Lifetime Application started. Press Ctrl+C to shut down.
[Kavita] [2023-04-01 12:28:58.232 +00:00  1] [Information] Microsoft.Hosting.Lifetime Hosting environment: Production
[Kavita] [2023-04-01 12:28:58.232 +00:00  1] [Information] Microsoft.Hosting.Lifetime Content root path: /kavita
someone@something:~$

此外,如果您有兴趣了解 Web 服务器是否在容器内运行,也许 Podman 的

top
子命令的输出可能对您感兴趣:

someone@something:~$ podman top <container-name>
USER   PID   PPID   %CPU    ELAPSED            TTY     TIME   COMMAND
root   1     0      0.000   29m47.804865961s   pts/0   0s     /bin/bash /entrypoint.sh 
root   3     1      0.671   29m47.805063227s   pts/0   12s    ./Kavita
someone@something:~$

据我所知,这意味着“不,没有网络服务器在运行”,但也许我错了。

containers podman
1个回答
1
投票

如果你只知道自己在做什么,那么你比 90% 的人在这里提问时准备得更好 :-)

你的基本例子对我来说很好。

$ podman run -dt -p 8888:80/tcp docker.io/library/httpd
Trying to pull docker.io/library/httpd:latest...
Getting image source signatures
...does its thing building up image layers...
4a12f492d4e153c76987f9fc8def761ac7c9d758011ba8859ec6ab9937668b07

$ podman ps -a
CONTAINER ID  IMAGE                            COMMAND           CREATED        STATUS            PORTS                    NAMES
4a12f492d4e1  docker.io/library/httpd:latest   httpd-foreground  4 seconds ago  Up 4 seconds ago  0.0.0.0:8888->80/tcp     pedantic_nightingale

$ curl http://localhost:8888/
<html><body><h1>It works!</h1></body></html>

我使用了 8888 端口,因为我已经在 8080 端口上运行了一些东西。

所以-如果你的不工作,要检查三件事。

  1. 容器是否真的在运行(用
    podman ps -a
    检查)?
  2. 是否可以使用端口? (
    sudo ss -lnp | grep 8080
    将显示正在监听该端口的内容)
  3. 容器里有webserver吗(
    podman logs <container-name>
    )

检查这三项,看看其中是否有任何线索。

(如果您在 Debian 上运行 podman v3.0,请注意很多在线文档都是针对更高版本的。基本的东西都是一样的,但是网络和 docker-sockets 等已经改变了)

© www.soinside.com 2019 - 2024. All rights reserved.