简体   繁体   English

Docker运行启动服务

[英]Docker run start services

I need nginx-openresty and redis in single docker container. 我需要在单个Docker容器中使用nginx-openresty和redis。 I have written docker file its working fine. 我已将docker文件写入其工作正常。 But thing i need to start my redis service after login into the docker bash to automate this I have written .sh file which contains instrutions like start and stop of redis server and nginx. 但是我登录到docker bash之后需要启动我的redis服务以使其自动化,所以我编写了.sh文件,其中包含诸如redis服务器和nginx的启动和停止之类的指令。 ENTRYPOINT ["./startup.sh"]

and .sh file is 和.sh文件是

cd /etc/redis-installation/utils
echo -n | ./install_server.sh
service redis_6379 stop
cd /
cp ./dump.rdb /var/lib/redis/6379/
service redis_6379 start
openresty

My problem is that docker container start and exist when shell execution completed. 我的问题是docker容器启动并在shell执行完成时存在。 How can stay the container keep running with nginx and redis in running state. 如何保持容器在nginx和redis处于运行状态下继续运行。

Try using docker-compose with a link between your app container and your redis container. 尝试将docker-compose与您的应用容器和redis容器之间的链接一起使用。 I suggest using the official redis container 我建议使用官方的Redis容器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM