构建容器时,Echo语句不在控制台中打印。
我能够看到以下信息
Step 1/3 : FROM jboss/wildfly:latest
b4680c565eae
Step 2/3 : ADD customization /opt/jboss/wildfly/customization/
bc78405babec
Removing intermediate container 7b22667b3310
Step 3/3 : CMD /opt/jboss/wildfly/customization/execute.sh
Running in 76f8bfe9ac95
5cb0fa9482f4
Removing intermediate container 76f8bfe9ac95
Successfully built 5cb0fa9482f4
Successfully tagged madhu/wildfly-mysql-javaee7:latest
execute.sh文件包含echo语句,但不写入控制台。
有兴趣知道我们应该如何调试脚本。
答案 0 :(得分:1)
CMD
中指定的脚本不会在构建时执行 - 它在运行时执行。您需要尝试docker run
查看其输出。
如果您想要更多输出(和/或更多有用的输出 - 当用于显示正在执行的命令时,echo
往往会丢掉重要的细节,例如文字和语法空间)你的echo
提供,修改CMD
或脚本来设置-x
shell命令。您可以将set -x
放入脚本(在shebang下),或将CMD
修改为:CMD ['/bin/bash', '-x', '/opt/jboss/wildfly/customization/execute.sh']
(如果shebang为{/bin/bash
,则可以执行此操作{1}},#!/bin/bash
如果shebang是/bin/sh
,等等。