简体   繁体   English

无法从主机访问 jupyter docker 容器

[英]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_modecommand部分,您的代码可能会工作。 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.

相关问题 无法从我的主机访问我的 ZMQ 订阅者,该订阅者在 http 服务器旁边的容器上运行 - Can't reach my ZMQ subscriber that running on a container alongside an http server, from my host machine 将数据从主机加载到 docker hive 容器 - Load data from host machine to docker hive container 从主机访问 mariadb docker-compose 容器 - Access mariadb docker-compose container from host-machine 无法访问 docker 容器内的 jupyter 笔记本 - Can't access jupyter notebook inside docker container Ansible 可以从 localhost 连接到 windows 机器,但不能从 docker 容器连接 - Ansible can connect to windows machine from localhost but not from docker container 来自 Docker 容器本地主机的 Jupyter 笔记本不起作用 - Jupyter notebook from Docker container localhost not working 如何在 docker 容器中使用参数运行本地主机脚本 - How to run local host machine script with arguments in a docker container 构建Docker容器时将流量路由到主机 - Route traffic to host machine when building a docker container 带有Python Web App的Docker容器-在主机(OSX)上连接到Postgres - Docker container with Python Web App - Connect to Postgres on Host machine (OSX) 尝试从 python 脚本(交互式代理)访问 docker 容器 - Try to reach docker container from python script (Interactive brokers)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM