[英]Can't reach jupyter docker container from host machine
I have a question about the https://hub.docker.com/r/jupyter/scipy-notebook .我有一个关于https://hub.docker.com/r/jupyter/scipy-notebook的问题。 I'm trying to run this image with docker-compose:
我正在尝试使用 docker-compose 运行此映像:
compose:撰写:
jupyter:
container_name: jupyter
build:
context: ./Jupyter
dockerfile: Dockerfile
ports:
- "8888:8888"
volumes:
- ./scripts:/opt/notebooks/connector
network_mode: "host"
command: bash -c "jupyter notebook --notebook-dir=/opt/notebooks --ip=* --port=8888 --no-browser --allow-root"
Dockerfile文件
FROM jupyter/scipy-notebook
EXPOSE 8888
and I can't reach it with http://locahost:8888 .... url.我无法通过http://locahost:8888 .... url 访问它。 I'm using windows 10 as host machine and tried reach other services from this docker compose and these work.
我使用 Windows 10 作为主机,并尝试从这个 docker compose 和这些工作访问其他服务。
Replace build
section with image: jupyter/scipy-notebook
.用
image: jupyter/scipy-notebook
替换build
部分image: jupyter/scipy-notebook
。 Also remove network_mode
and command
sections, and your code may work.同时删除
network_mode
和command
部分,您的代码可能会工作。 I don't know why your code is not running in this situation, but I think it must be related to the command
section, which is replacing the default command of the jupyter image.我不知道为什么您的代码在这种情况下没有运行,但我认为它必须与
command
部分有关,该部分正在替换 jupyter 图像的默认命令。 Furthermore, you don't need to create a Dockerfile to just add EXPOSE;此外,您无需创建 Dockerfile 即可添加 EXPOSE; you can use the image directly.
您可以直接使用图像。
You cannot use the host network mode and publish ports together不能同时使用主机网络模式和发布端口
docker run --rm -it --net=host -p80:80 yeasy/simple-web:latest
WARNING: Published ports are discarded when using host network mode警告:使用主机网络模式时,已发布的端口将被丢弃
For the second part, to reach the host from inside the container, use host.docker.internal
dns对于第二部分,要从容器内部访问主机,请使用
host.docker.internal
dns
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.