mkdocs-material icon indicating copy to clipboard operation
mkdocs-material copied to clipboard

the logo link redirect to 0.0.0.0:8000 when run mkdocs material by docker

Open laoba25 opened this issue 6 years ago • 7 comments

  1. run mkdocs material on docker in remote host:
#login to remote host
ssh 192.168.10.100
#start mkdocs-material server
sudo docker run -d --name abc -v /tmp/abc:/docs -p 5800:8000 --workdir /docs squidfunk/mkdocs-material serve -a 0.0.0.0:8000
  1. view the mkdocs via another machine:

image

Web page can be displayed normally.

  1. view the logo link tag value:

image

image

The logo button href attribute is not expected.

  1. click the logo button

When I click the button , the chrome tells me can not open this page.

image

My question is how to fix is this problem.Please help me...Thanks a lot...

laoba25 avatar Feb 15 '20 07:02 laoba25

Please read https://github.com/squidfunk/mkdocs-material/issues/238#issuecomment-367486396 and https://github.com/mkdocs/mkdocs/issues/1239#issuecomment-307383410

squidfunk avatar Feb 15 '20 08:02 squidfunk

Please read #238 (comment) and mkdocs/mkdocs#1239 (comment)

Thank you very much , squidfunk . I have already read the comments before.

Change the site_url value could not solve my problem.

So I am really confused.

How can I correctly deploy the mkdocs material on docker , so I can fix the logo link problem, When I use the remote ip open the mkdocs webpage , click the logo link can redirect to the correct ip address.

If I need custom the header.html?

Thanks .

laoba25 avatar Feb 15 '20 09:02 laoba25

That's the point - it should not be deployed. You shouldn't run the Docker container in production. From the second comment:

MkDocs is a static site generator. Its intended use case is to generate static files which are deployed by being uploaded to a static file server. You could use AWS' static file server (see their docs), or if you already have an nginx instance running, you could point it at a directory of static files (see those docs). In either case, run mkdocs build and then copy the contents of the site directory to the appropriate location on your server. That is the only type of deployment we support. Any other type of deployment is out of scope for MkDcos, and not something we can help with.

squidfunk avatar Feb 15 '20 09:02 squidfunk

Thank you very much , squidfunk . So I need change the deploy method. I am clear now.Thanks.

laoba25 avatar Feb 15 '20 09:02 laoba25

@squidfunk Sorry, maybe I missed something but what's the answer for local run via Docker? When I do

docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material serve

I just get the "0.0.0.0" error when clicking the logo.

borekb avatar May 07 '20 18:05 borekb

Just drop the serve (as it's the default) or add the dev address as in:

https://github.com/squidfunk/mkdocs-material/blob/9a0c3e9094256a41d695da00afca733201406f43/Dockerfile#L57

squidfunk avatar May 07 '20 19:05 squidfunk

I wanted to achieve running on localhost:8000 and keeping me on localhost:8000 after clicking the home link. As per our Gitter discussion, this is currently only possibly by overriding the partial, like this:

In overrides/partials/header.html:

    <!-- Link to home -->
    <a
      href="/"
      title="{{ config.site_name }}"
      class="md-header-nav__button md-logo"
      aria-label="{{ config.site_name }}"
    >
      {% include "partials/logo.html" %}
    </a>

(I only need "/" so I removed the original, more complex expression including site_url.)

borekb avatar May 07 '20 20:05 borekb