我在fedora 22上的dockerfile
FROM java:latest
ENV HBASE_VERSION=1.1.0.1
RUN groupadd -r hbase && useradd -m -r -g hbase hbase
USER hbase
ENV HOME=/home/hbase
# Download'n extract hbase
RUN cd /home/hbase && \
wget -O - -q \
http://apache.mesi.com.ar/hbase/${HBASE_VERSION}/hbase-${HBASE_VERSION}-bin.tar.gz \
| tar --strip-components=1 -zxf -
# Upload local configuration
ADD ./conf/ /home/hbase/conf/
USER root
RUN chown -R hbase:hbase /home/hbase/conf
USER hbase
# Prepare data volumes
RUN mkdir /home/hbase/data
RUN mkdir /home/hbase/logs
VOLUME /home/hbase/data
VOLUME /home/hbase/logs
# zookeeper
EXPOSE 2181
# HBase Master API port
EXPOSE 60000
# HBase Master Web UI
EXPOSE 60010
# Regionserver API port
EXPOSE 60020
# HBase Regionserver web UI
EXPOSE 60030
WORKDIR /home/hbase
CMD /home/hbase/bin/hbase master start
据我所知,当我设置" FROM java:latest"我当前的dockerfile覆盖了那个,所以JAVA_HOME必须设置为java:latest?我对吗?这个Dockerfile已构建完毕,但是当我" docker run"它显示"未找到JAVA_HOME"错误。我该如何正确设置?
答案 0 :(得分:1)
使用ENV指令,例如ENV JAVA_HOME /abc/def
doc https://docs.docker.com/reference/builder/#env
答案 1 :(得分:0)
添加到~./bashrc
(或全局/etc/bashrc
:
export JAVA_HOME=/usr/java/default
export PATH=$JAVA_HOME/bin:$PATH