Skip to content

Running "mkdocs serve" through Docker results in "Connection reset by peer" #7197

@marc-guenther

Description

@marc-guenther

Context

This is on Mac, using Docker 26.0.0, and mkdocs 1.6.0, in a completely fresh project:

$ docker --version             
Docker version 26.0.0, build 2ae903e
$ docker run --rm  squidfunk/mkdocs-material --version
mkdocs, version 1.6.0 from /usr/local/lib/python3.11/site-packages/mkdocs (Python 3.11)
$ docker run --rm -v .:/docs squidfunk/mkdocs-material new empty-project
$ cd empty-project

Bug description

When I run the "serve" command:

$ docker run --rm -v .:/docs -p 8000:8000 squidfunk/mkdocs-material serve
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Documentation built in 0.11 seconds
INFO    -  [12:44:48] Watching paths for changes: 'docs', 'mkdocs.yml'
INFO    -  [12:44:48] Serving on http://127.0.0.1:8000/

a subsequent curl does not work:

$ curl http://localhost:8000
curl: (56) Recv failure: Connection reset by peer

When i run it without the serve argument:

$ docker run --rm -v .:/docs -p 8000:8000 squidfunk/mkdocs-material
WARNING -  Config value 'dev_addr': The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server instead.
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Documentation built in 0.11 seconds
INFO    -  [12:45:47] Watching paths for changes: 'docs', 'mkdocs.yml'
INFO    -  [12:45:47] Serving on http://0.0.0.0:8000/

everything is fine.

Please note the different IP address. It fails, when it binds to 127.0.0.1, but works, when it binds to 0.0.0.0:

$ docker run --rm -v .:/docs -p 8000:8000 squidfunk/mkdocs-material serve -a 0.0.0.0:8000

behaves exactly as leaving out the "serve" argument.

Related links

Reproduction

I have no idea what to put here, as this is an issue running through Docker, which happens with every project.
empty.zip

Steps to reproduce

x

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    working as intendedIssue reports behavior in line with specification

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions