用docker-compose创建容器后,容器一直处于exit 0 状态无法启动,docker logs看日志显示
Interactive shell
在网上翻了半天,在yml文件里加入以下2个参数就好了
stdin_open: true
tty: true
查了查docker-compose语法
Compose specification | Docker Documentation
stdin_open
stdin_open configures service containers to run with an allocated stdin.
tty
tty configure service container to run with a TTY.
就类似用docker run时用的 -it参数,我的理解是以一种交互式终端方式启动容器,但更具体的为什么要这样我就不是很明白了,有大佬知道可以讲一讲。