I have a container that has a serivce app, that is built with a dockerfile.
我有一个容器,里面有一个servicce应用程序,它是用dockerfile构建的。
services:
app:
build: docker
Inside my docker file i have at the end, a script.sh that i run to initialize drupal and databases
在我的docker文件中,我在最后有一个脚本.sh,我运行它来初始化Drupal和数据库
COPY script.sh /sh/script.sh
RUN chmod +x /sh/script.sh
CMD /sh/script.sh
WORKDIR /var/www
Inside my script.sh i have this
在我的脚本中,我有这个
#!/usr/bin/env bash
php ./web/vendor/bin/drush cim -y &
wait
php ./web/vendor/bin/drush cr &
wait
exit 0
Everything works just fine the problem i have is that the service app stop right after it clear and rebuilt the cache. The problem is everytime I start the service app again it runs the dockerfile which run the script.sh to finally stop the service again
So if anyone have a solution to this on why it does this and how to make so that the service doesn't stop when it finish the script.sh
一切都很好,但我遇到的问题是,服务应用程序在清除后立即停止,并重新构建了缓存。问题是,每次我再次启动服务应用程序时,它都会运行dockerfile,该文件会运行script.sh,最终会再次停止服务。因此,如果有人对此有解决方案,那么它为什么要这样做以及如何操作,这样服务就不会在脚本.sh结束时停止
Thanks for your helps
谢谢你的帮助
更多回答
优秀答案推荐
At the end of your entrypoint, put a command that will prevent the container from quitting, i.e.:
在您的入口点的末尾,放置一个防止容器退出的命令,即:
#!/usr/bin/env bash
set -e
php ./web/vendor/bin/drush cim -y
php ./web/vendor/bin/drush cr
tail -f -s5 /dev/null
更多回答
我是一名优秀的程序员,十分优秀!