从dockerfile pod开启在线zookeeper“Crash loop back off”

时间:2016-12-14 16:58:15

标签: apache-zookeeper openshift-origin

我想在Openshift-origin online(下一代)上部署应用程序。将有至少4个pod通过服务进行通信。

在第一个POD中,我必须运行Zookeeper。所以我创建了POD,我的来自docker image的Zookeeper将会运行,但是POD的状态是:Crash loop off off。

我创建了新项目

oc new-project my-project

我创建了一个新的app来从docker部署我的zookeeper

oc new-app mciz/zookeeper-docker-infispector --name zookeeper

输出消息是:

--> Found Docker image 51220f2 (11 minutes old) from Docker Hub for "mciz/zookeeper-docker-infispector"

* An image stream will be created as "zookeeper:latest" that will track this image
* This image will be deployed in deployment config "zookeeper"
* Ports 2181/tcp, 2888/tcp, 3888/tcp will be load balanced by service "zookeeper"
  * Other containers can access this service through the hostname "zookeeper"
* This image declares volumes and will default to use non-persistent, host-local storage.
  You can add persistent volumes later by running 'volume dc/zookeeper --add ...'
* WARNING: Image "mciz/zookeeper-docker-infispector" runs as the 'root' user which may not be permitted by your cluster administrator

--> Creating resources with label app=zookeeper ...
imagestream "zookeeper" created
deploymentconfig "zookeeper" created
service "zookeeper" created
--> Success
Run 'oc status' to view your app.

然后我运行了pods列表:

oc get pods

带输出:

NAME               READY   STATUS             RESTART      AGE
zookeeper-1-mrgn1  0/1     CrashLoopBackOff   5            5m

然后我运行了日志:

 oc logs -p zookeeper-1-mrgn1 

带输出:

JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
grep: /opt/zookeeper/bin/../conf/zoo.cfg: No such file or directory
mkdir: can't create directory '': No such file or directory
log4j:WARN No appenders could be found for logger         (org.apache.zookeeper.server.quorum.QuorumPeerConfig).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig     for more info.
Invalid config, exiting abnormally

我的dockerfile:

FROM openjdk:8-jre-alpine
MAINTAINER mciz

ARG MIRROR=http://apache.mirrors.pair.com
ARG VERSION=3.4.6

LABEL name="zookeeper" version=$VERSION

RUN apk add --no-cache wget bash \
    && mkdir /opt \
    && wget -q -O - $MIRROR/zookeeper/zookeeper-$VERSION/zookeeper-    $VERSION.tar.gz | tar -xzf - -C /opt \
    && mv /opt/zookeeper-$VERSION /opt/zookeeper \
    && cp /opt/zookeeper/conf/zoo_sample.cfg     /opt/zookeeper/conf/zoo.cfg 

EXPOSE 2181 2888 3888

WORKDIR /opt/zookeeper

VOLUME ["/opt/zookeeper/conf"]

ENTRYPOINT ["/opt/zookeeper/bin/zkServer.sh"]
CMD ["start-foreground"]

1 个答案:

答案 0 :(得分:2)

new-app命令输出中有警告:

WARNING: Image "mciz/zookeeper-docker-infispector" runs as the 'root' user which may not be permitted by your cluster administrator

您应该将docker镜像修复为不以root身份运行(或告诉OpenShift允许此项目容器以root身份运行)。

在Openshift中有一个Zookeeper图像和模板的具体示例。

https://github.com/openshift/origin/tree/master/examples/zookeeper

请注意Dockerfile更改为以非root用户身份运行容器