使用docker-compose从mac osx的网桥网络上的docker容器访问IP

时间:2019-11-29 23:15:04

标签: macos docker hadoop docker-compose

我正在尝试从hadoop-cluster从docker-compose上的容器访问webUI。链接:https://github.com/big-data-europe/docker-hadoop

Docker-Compose文件具有以下内容:

version: "3"

services:
  namenode:
    image: bde2020/hadoop-namenode:2.0.0-hadoop3.1.3-java8
    container_name: namenode
    ports:
      - 9870:9870
    volumes:
      - hadoop_namenode:/hadoop/dfs/name
    environment:
      - CLUSTER_NAME=test
    env_file:
      - ./hadoop.env

  datanode:
    image: bde2020/hadoop-datanode:2.0.0-hadoop3.1.3-java8
    container_name: datanode
    volumes:
      - hadoop_datanode:/hadoop/dfs/data
    environment:
      SERVICE_PRECONDITION: "namenode:9870"
    env_file:
      - ./hadoop.env

  resourcemanager:
    image: bde2020/hadoop-resourcemanager:2.0.0-hadoop3.1.3-java8
    container_name: resourcemanager
    environment:
      SERVICE_PRECONDITION: "namenode:9870 datanode:9864"
    env_file:
      - ./hadoop.env

  nodemanager1:
    image: bde2020/hadoop-nodemanager:2.0.0-hadoop3.1.3-java8
    container_name: nodemanager
    environment:
      SERVICE_PRECONDITION: "namenode:9870 datanode:9864 resourcemanager:8088"
    env_file:
      - ./hadoop.env

  historyserver:
    image: bde2020/hadoop-historyserver:2.0.0-hadoop3.1.3-java8
    container_name: historyserver
    environment:
      SERVICE_PRECONDITION: "namenode:9870 datanode:9864 resourcemanager:8088"
    volumes:
      - hadoop_historyserver:/hadoop/yarn/timeline
    env_file:
      - ./hadoop.env

volumes:
  hadoop_namenode:
  hadoop_datanode:
  hadoop_historyserver:

如果我运行命令“ docker-compose up”,则可以通过docker ps看到容器和打开的端口。通过网络检查,我可以看到IP,但是无法访问它们。

我发现有关Mac OSX上的主机网络无法正常工作的信息。但是这个网络是一个桥接网络。

如何从容器访问webUI?

1 个答案:

答案 0 :(得分:0)

要访问Namenode用户界面,请使用localhost:9870,因为这是您转发的端口。您不需要“从其他容器”访问UI

这是您为

打开端口的唯一容器