Skip to content

mdbook connections reset when run inside container #2226

@pozix604

Description

@pozix604

Problem

mdbook serve doesn't seem to be running properly when inside a Podman container. Everything works but serving. The logging indicates that it starts listening on port 3000, but then upon connect, the connection is dropped immediately.

If I shell into the container, the server is working and responds to requests.

This makes it look like podman is not working, but then all other servers ,like python's http.server, work properly in this container, just mdbook's connections are reset.

Containerfile:

$ cat Containerfile
FROM    alpine
RUN     apk update && apk upgrade
RUN     apk add mdbook
RUN     yes | mdbook init /mnt
WORKDIR /mnt
CMD     ["mdbook", "serve"]

Build:

$ podman build -t mdbook_test .
<lots of output>
Successfully tagged localhost/mdbook_test:latest

Running log:

$ podman run -it --rm -p 3000:3000 mdbook_test
2023-10-26 13:05:16 [INFO] (mdbook::book): Book building has started
2023-10-26 13:05:16 [INFO] (mdbook::book): Running the html backend
2023-10-26 13:05:16 [INFO] (mdbook::cmd::serve): Serving on: http://localhost:3000
2023-10-26 13:05:16 [INFO] (mdbook::cmd::watch): Listening for changes...
2023-10-26 13:05:16 [INFO] (warp::server): Server::run; addr=[::1]:3000
2023-10-26 13:05:16 [INFO] (warp::server): listening on http://[::1]:3000

Try to connect from host:

$ telnet localhost 3000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

Try to connect from inside container:

$ podman exec -it vibrant_dirac sh
# telnet localhost 3000
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1

HTTP/1.1 200 OK
...

Steps

No response

Possible Solution(s)

No response

Notes

I tried using mdbook serve --hostname 127.0.0.1, same issue.

Version

# mdbook --version
mdbook v0.4.28

Same issue if mdbook is installed from source, v0.4.35.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-InstallationArea: Installation of mdbook itselfC-enhancementCategory: Enhancement or feature requestCommand-serveCommand: serveS-Not-wrongStatus: Possibly not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions