保险丝 7:执行命令时出错:零:创建 docker 个图像时

fuse 7 : Error executing command: by zero : when docker images is created

从 Redhat Fuse 7 创建 Docker 映像后,我进入容器 bin 文件夹并执行 ./clinet 命令。 已加载融合客户端实例

karaf@3e06e92ec257:/opt/karaf/bin$ ./client
Logging in as admin

 ____          _   _   _       _     _____
|  _ \ ___  __| | | | | | __ _| |_  |  ___|   _ ___  ___
| |_) / _ \/ _` | | |_| |/ _` | __| | |_ | | | / __|/ _ \
|  _ <  __/ (_| | |  _  | (_| | |_  |  _|| |_| \__ \  __/
|_| \_\___|\__,_| |_| |_|\__,_|\__| |_|   \__,_|___/___|

  Red Hat Fuse (7.0.0.fuse-000191-redhat-1)
  http://www.redhat.com/products/jbossenterprisemiddleware/fuse/

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.

Open a browser to http://localhost:8181/hawtio to access the management console

Hit '<ctrl-d>' or 'shutdown' to shutdown Red Hat Fuse.

admin@root()>

但是按下任何键,它返回以下错误并且实例关闭

admin@root()> Error executing command: / by zero

示例Docker文件和命令

docker 运行 --name fuse -d -p 1099:1099 -p 8101:8101 -p 44444:44444 redhat-fuse-v1

docker exec -it fuse /opt/karaf/bin/client

docker logs -f fuse

FROM openjdk:8-slim
MAINTAINER Jayashankar C <jshankarc1@gmail.com>

ENV KARAF_USER karaf
ENV KARAF_UID 8181
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
ENV JAVA_MAX_MEM 256m
ENV KARAF_EXEC exec

COPY fuse-karaf-7.0.0.fuse-000191-redhat-1.zip /tmp/fuse-karaf.zip
COPY org.ops4j.pax.url.mvn.cfg /tmp
COPY users.properties /tmp

RUN groupadd -r $KARAF_USER --gid=$KARAF_UID && useradd -rm -g $KARAF_USER --uid=$KARAF_UID $KARAF_USER

RUN mkdir -p /opt/karaf \
    && unzip -o /tmp/fuse-karaf.zip -d /opt/karaf \
    && mv /opt/karaf/fuse-karaf-7.0.0.fuse-000191-redhat-1/* /opt/karaf > /dev/null 2>&1 \
    && ls /opt/karaf -ltr \
    && rm /tmp/fuse-karaf.zip \
    && cp -f /tmp/org.ops4j.pax.url.mvn.cfg  opt/karaf/etc \
    && cp -f /tmp/users.properties opt/karaf/etc \
    && cat /opt/karaf/etc/org.ops4j.pax.url.mvn.cfg \
    && mkdir -p /opt/karaf/data /opt/karaf/data/log \
    && chown -R $KARAF_USER.$KARAF_USER /opt/karaf \
    && chmod 700 /opt/karaf/data

EXPOSE 1099 8101 44444

USER $KARAF_USER

CMD ["/opt/karaf/bin/karaf", "run"]

错误日志

2018-05-31 18:14:21,757 | ERROR | h console user admin | o.a.k.s.s.ShellUtil              | 143 - org.apache.karaf.shell.core - 4.2.0.fuse-000237-redhat-1 | Exception caught while executing command
java.lang.ArithmeticException: / by zero
        at org.aesh.readline.Buffer.printInsertedData(Buffer.java:570) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.aesh.readline.Buffer.insert(Buffer.java:227) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.aesh.readline.AeshConsoleBuffer.writeChar(AeshConsoleBuffer.java:128) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.aesh.readline.Readline$AeshInputProcessor.parse(Readline.java:262) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.aesh.readline.Readline$AeshInputProcessor.access0(Readline.java:174) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.aesh.readline.Readline.readInput(Readline.java:95) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.aesh.readline.Readline.access00(Readline.java:57) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.aesh.readline.Readline$AeshInputProcessor.lambda$start(Readline.java:333) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.jline.reader.impl.TerminalConnection.openBlocking(TerminalConnection.java:152) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.jline.reader.impl.LineReaderImpl.readInput(LineReaderImpl.java:137) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:275) ~[141:org.apache.karaf.shell.aesh-jline:4.2.0.fuse-000237-redhat-1]
        at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.readCommand(ConsoleSessionImpl.java:436) [143:org.apache.karaf.shell.core:4.2.0.fuse-000237-redhat-1]
        at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:394) [143:org.apache.karaf.shell.core:4.2.0.fuse-000237-redhat-1]
        at java.lang.Thread.run(Thread.java:748) [?:?]

如果您稍早查看日志,您会发现以下事件:

852 [sshd-SshClient[3a82f6ef]-nio2-thread-3] DEBUG org.apache.sshd.client.channel.ChannelShell - doOpenPty(ChannelShell[id=0, recipient=0]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) Send SSH_MSG_CHANNEL_REQUEST env: {TERM=null, LC_CTYPE=en.UTF-8}

问题是 TERM=null 环境变量导致 NullPointerException

您需要 运行 以下命令:

docker exec -it -e TERM=${TERM} fuse /opt/karaf/bin/client

在较早的 docker 版本中,您可以 运行 以下操作:

docker exec -it fuse bash -c "export TERM=${TERM} /opt/karaf/bin/client"