CMD "文件"和CMD["文件",run]的区别

dockerfile 部署tomcat的时候,看网上很多教学 dockerfile 中有这个一个命令

CMD ["/usr/local/apache-tomcat-9.0.60/bin/catalina.sh","run"]

那么和下面这个有什么区别呢?

CMD /usr/local/apache-tomcat-9.0.60/bin/catalina.sh

run 在当前shell窗口运行,命令行输出日志时用。

具体查看 tomcat 的catalina.sh 参数用法:

Usage: catalina.sh ( commands ... )

commands:
  debug             Start Catalina in a debugger
  debug -security   Debug Catalina with a security manager
  jpda start        Start Catalina under JPDA debugger
  run               Start Catalina in the current window
  run -security     Start in the current window with security manager
  start             Start Catalina in a separate window
  start -security   Start in a separate window with security manager
  stop              Stop Catalina, waiting up to 5 seconds for the process to end
  stop n            Stop Catalina, waiting up to n seconds for the process to end
  stop -force       Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
  stop n -force     Stop Catalina, wait up to n seconds and then use kill -KILL if still running
  configtest        Run a basic syntax check on server.xml - check exit code for result
  version           What version of tomcat are you running?
Note: Waiting for the process to end and use of the -force option require that $CATALINA_PID is defined

源码中的参数截图

img