我正在尝试创建一个Dockerfile来设置我的hadoop环境。 在其中一个步骤中,我需要在我的bashrc文件中添加一些行。这就是我在做的事情:
RUN wget http://apache.mirror.digitalpacific.com.au/hadoop/common/current/hadoop-2.7.2.tar.gz
RUN tar -zxvf hadoop-2.7.2.tar.gz
RUN cp -R hadoop-2.7.2 /usr/local/hadoop
RUN cd /usr/local/hadoop
RUN cat << EOF >> ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
EOF
RUN source ~/.bashrc
但是我收到以下错误:
Step 10 : EXPORT
Unknown instruction: EXPORT
知道如何编辑我的bashrc文件?
注意:
我也尝试过:
ENV JAVA_HOME /usr/lib/jvm/java-1.7.0-openjdk-amd64
ENV HADOOP_INSTALL /usr/local/hadoop
ENV PATH $PATH:$HADOOP_INSTALL/bin
ENV PATH $PATH:$HADOOP_INSTALL/sbin
ENV HADOOP_MAPRED_HOME $HADOOP_INSTALL
ENV HADOOP_COMMON_HOME $HADOOP_INSTALL
ENV HADOOP_HDFS_HOME $HADOOP_INSTALL
ENV YARN_HOME $HADOOP_INSTALL
ENV HADOOP_COMMON_LIB_NATIVE_DIR $HADOOP_INSTALL/lib/native
ENV HADOOP_OPTS "-Djava.library.path=$HADOOP_INSTALL/lib"
和
RUN echo $'export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64' >> ~/.bashrc
RUN echo $'export HADOOP_INSTALL=/usr/local/hadoop' >> ~/.bashrc
RUN echo $'export PATH=$PATH:$HADOOP_INSTALL/bin' >> ~/.bashrc
RUN echo $'export PATH=$PATH:$HADOOP_INSTALL/sbin' >> ~/.bashrc
RUN echo $'export HADOOP_MAPRED_HOME=$HADOOP_INSTALL' >> ~/.bashrc
RUN echo $'export HADOOP_COMMON_HOME=$HADOOP_INSTALL' >> ~/.bashrc
RUN echo $'export HADOOP_HDFS_HOME=$HADOOP_INSTALL' >> ~/.bashrc
RUN echo $'export YARN_HOME=$HADOOP_INSTALL' >> ~/.bashrc
RUN echo $'export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native' >> ~/.bashrc
RUN echo $'export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"' >> ~/.bashrc
仍然没有成功
答案 0 :(得分:0)
使用echo:
尝试Dockerfile多行语法RUN echo $'this is\n\
a multiline\n\
string\n'\
>> ~/.bashrc