search

Home  >  Q&A  >  body text

docker容器启动时里面的lnmp服务器如何也跟着启动

docker容器启动时里面的lnmp服务器如何也跟着启动?
启动后怎么保证容器不自动关闭?

曾经蜡笔没有小新曾经蜡笔没有小新2768 days ago914

reply all(4)I'll reply

  • 習慣沉默

    習慣沉默2017-04-27 09:04:16

    Docker recommends one container and one service. You can split nginx, mysql, PHP-FPM (PHP) into different containers. After you split it, you can use docker's restart mechanism to ensure the availability of the service. You can refer to me This way docker-node.js

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-04-27 09:04:16

    The principle of docker is that the container run by docker run is essentially just a process, and the backend calls various system calls to isolate it, making it look like a virtual machine.

    Docker run The running process and its sub-processes, as long as the main process does not die, the docker container will not hang.

    Based on this, we can regard supervisord as the main process and start php and nginx together. The php and nginx processes are managed by supervisord.


    Ready-made dockerfile.

    supervisord process management+nginx+php7

    php+nginx+supervisord dockerfile:
    https://github.com/qiukeren/d...

    Well, salt-minion will be installed at the same time. If you don’t need it, just customize it yourself.

    Project address:

    https://github.com/qiukeren/d..., directly execute bash build.sh to generate a container.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-27 09:04:16

    The answer above did not solve the problem

    This article can solve the poster’s problem

    https://javablog.net/page/250...

    No one can stop you if you have to run multiple processes in one dock. Feel free

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-04-27 09:04:16

    Make sure that lnmp is also started after the container is started. Make sure that nginx mysql php is started in the foreground, otherwise the container detects that these processes have left the container and started in the background, and the container itself will automatically close. Regarding the containerization of lnmp, you can refer to https://www.centos.bz/2017/02...

    reply
    0
  • Cancelreply