docker内部的Spring Shell应用

时间:2018-07-20 19:47:13

标签: docker spring-shell

我正在尝试在docker容器内部署/运行spring shell应用程序。它正在启动,但是在尝试打开CLI时正在归档。

2018-07-20 19:24:44.588  INFO 1 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-07-20 19:24:44.597 ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.io.IOError: java.io.IOException: Unable to parse columns
        at org.jline.terminal.impl.AbstractPosixTerminal.getSize(AbstractPosixTerminal.java:61) ~[jline-3.4.0.jar!/:na]
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:481) ~[jline-3.4.0.jar!/:na]
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:390) ~[jline-3.4.0.jar!/:na]
        at org.springframework.shell.jline.InteractiveShellApplicationRunner$JLineInputProvider.readInput(InteractiveShellApplicationRunner.java:115) ~[spring-shell-core-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
        at org.springframework.shell.Shell.run(Shell.java:125) ~[spring-shell-core-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
        at org.springframework.shell.jline.InteractiveShellApplicationRunner.run(InteractiveShellApplicationRunner.java:84) ~[spring-shell-core-2.0.0.RELEASE.jar!/:2.0.0.RELEASE]
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:788) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:778) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:335) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
        at com.robustwealth.simulator.RwFixEngineApplication.main(RwFixEngineApplication.java:14) [classes!/:0.0.1-SNAPSHOT]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [app.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [app.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [app.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [app.jar:0.0.1-SNAPSHOT]
Caused by: java.io.IOException: Unable to parse columns
        at org.jline.terminal.impl.ExecPty.doGetInt(ExecPty.java:278) ~[jline-3.4.0.jar!/:na]
        at org.jline.terminal.impl.ExecPty.doGetSize(ExecPty.java:263) ~[jline-3.4.0.jar!/:na]
        at org.jline.terminal.impl.ExecPty.getSize(ExecPty.java:170) ~[jline-3.4.0.jar!/:na]
        at org.jline.terminal.impl.AbstractPosixTerminal.getSize(AbstractPosixTerminal.java:59) ~[jline-3.4.0.jar!/:na]

这可能是因为它无法对docker内部的任何终端进行罚款。我们该如何克服呢?

docker文件

FROM frolvlad/alpine-oraclejdk8:slim
VOLUME /tmp
ADD simulator-0.0.1-SNAPSHOT.jar app.jar
RUN sh -c 'touch /app.jar'
ENV JAVA_OPTS=""
EXPOSE 5432
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=uat -jar /app.jar" ]

1 个答案:

答案 0 :(得分:0)

我使用-t选项运行容器以跳过该错误。 如果您想与容器-it

进行交互

编译图像

$ docker build -f Dockerfile -t my-spring-shell-image .

查看图片注册表

$ docker images

运行图像!

$ docker run -t -p 5432: 5432 my-spring-shell-image

如果要访问终端,则必须输入

$ docker run -it -p 5432: 5432 my-spring-shell-image