2016-11-19 167 views
1

我使用gettyimages作爲火花主容器,同時我有一個火花圖像,將啓動一個奴隸節點。這是我相應的碼頭文件。連接火花大師火花奴隸通過碼頭組成

FROM debian:jessie 

RUN apt-get update \ 
&& apt-get install -y locales \ 
&& dpkg-reconfigure -f noninteractive locales \ 
&& locale-gen C.UTF-8 \ 
&& /usr/sbin/update-locale LANG=C.UTF-8 \ 
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ 
&& locale-gen \ 
&& apt-get clean \ 
&& rm -rf /var/lib/apt/lists/* 

# Users with other locales should set this in their derivative image 
ENV LANG en_US.UTF-8 
ENV LANGUAGE en_US:en 
ENV LC_ALL en_US.UTF-8 

RUN apt-get update \ 
&& apt-get install -y curl unzip \ 
&& apt-get clean \ 
&& rm -rf /var/lib/apt/lists/* 


# JAVA 
ARG JAVA_MAJOR_VERSION=8 
ARG JAVA_UPDATE_VERSION=92 
ARG JAVA_BUILD_NUMBER=14 
ENV JAVA_HOME /usr/jdk1.${JAVA_MAJOR_VERSION}.0_${JAVA_UPDATE_VERSION} 

ENV PATH $PATH:$JAVA_HOME/bin 
RUN curl -sL --retry 3 --insecure \ 
    --header "Cookie: oraclelicense=accept-securebackup-cookie;" \ 
    "http://download.oracle.com/otn-pub/java/jdk/${JAVA_MAJOR_VERSION}u${JAVA_UPDATE_VERSION}-b${JAVA_BUILD_NUMBER}/server-jre-${JAVA_MAJOR_VERSION}u${JAVA_UPDATE_VERSION}-linux-x64.tar.gz" \ 
    | gunzip \ 
    | tar x -C /usr/ \ 
    && ln -s $JAVA_HOME /usr/java \ 
    && rm -rf $JAVA_HOME/man 

# HADOOP 
ENV HADOOP_VERSION 2.7.2 
ENV HADOOP_HOME /usr/hadoop-$HADOOP_VERSION 
ENV HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop 
ENV PATH $PATH:$HADOOP_HOME/bin 
RUN curl -sL --retry 3 \ 
    "http://archive.apache.org/dist/hadoop/common/hadoop-$HADOOP_VERSION/hadoop-$HADOOP_VERSION.tar.gz" \ 
    | gunzip \ 
    | tar -x -C /usr/ \ 
&& rm -rf $HADOOP_HOME/share/doc \ 
&& chown -R root:root $HADOOP_HOME 

# SPARK 
ENV SPARK_VERSION 2.0.1 
ENV SPARK_PACKAGE spark-${SPARK_VERSION}-bin-without-hadoop 
ENV SPARK_HOME /usr/spark-${SPARK_VERSION} 
ENV SPARK_DIST_CLASSPATH="$HADOOP_HOME/etc/hadoop/*:$HADOOP_HOME/share/hadoop/common/lib/*:$HADOOP_HOME/share/hadoop/common/*:$HADOOP_HOME/share/hadoop/hdfs/*:$HADOOP_HOME/share/hadoop/hdfs/lib/*:$HADOOP_HOME/share/hadoop/hdfs/*:$HADOOP_HOME/share/hadoop/yarn/lib/*:$HADOOP_HOME/share/hadoop/yarn/*:$HADOOP_HOME/share/hadoop/mapreduce/lib/*:$HADOOP_HOME/share/hadoop/mapreduce/*:$HADOOP_HOME/share/hadoop/tools/lib/*" 
ENV PATH $PATH:${SPARK_HOME}/bin 
RUN curl -sL --retry 3 \ 
    "http://d3kbcqa49mib13.cloudfront.net/${SPARK_PACKAGE}.tgz" \ 
    | gunzip \ 
    | tar x -C /usr/ \ 
&& mv /usr/$SPARK_PACKAGE $SPARK_HOME \ 
&& chown -R root:root $SPARK_HOME 

WORKDIR $SPARK_HOME 
CMD ["bin/spark-class","org.apache.spark.deploy.worker.Worker", //TODO: Figure out what this should be] 

我在想如何才能讓奴隸能夠訪問主人的主機和端口,如果我通過碼頭撰寫這個設置。

回答

1

比方說你有docker-compose是這樣的:你的火花從

version: '2' 
services: 
    spark-master: 
    image: spark-master 
    ports: 
    - "7077:7077" 
    - "8080:8080" 
    spark-slave1: 
    image: spark-slave 
    ports: 
    - "8081:8081" 
    depends_on: 
    - spark-master 
Dockerfile

您需要定義主像: ./bin/spark-class org.apache.spark.deploy.worker.Worker spark://IP:PORT

但使用的IP地址是不怎麼好主意。所以,你可以使用主機名從泊塢窗 - 撰寫(spark-master是主機名並將其添加到/etc/hosts):

CMD ["bin/spark-class","org.apache.spark.deploy.worker.Worker", "spark://spark-master:7077"] 

現在你可以去:
DOCKER_IP:8080 - >看1工人「工人」
DOCKER_IP:8081 - >並查看工作人員的詳細信息

如果您希望有更多的工作人員,則可以將其他服務添加到docker-compose。以下docker-compose將創建2名工作人員 - 端口8081上的1名工作人員的詳細信息以及8082上的第二名工作人員的詳細信息。

version: '2' 
services: 
    spark-master: 
    image: spark-master 
    ports: 
    - "7077:7077" 
    - "8080:8080" 
    spark-slave1: 
    image: spark-slave 
    ports: 
    - "8081:8081" 
    depends_on: 
    - spark-master 
    spark-slave2: 
    image: spark-slave 
    ports: 
    - "8082:8081" 
    depends_on: 
    - spark-master