I sealed php and nginx together in a docker. How can I make nginx and php start automatically?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-16 12:59:56
0
2
371

Every time I create a new container, I have to enter the container and start nginx and php. How can I make nginx and php start automatically every time I create a new container?

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(2)
淡淡烟草味

You can use supervisord to manage

  1. First enter the container to install supervisord, (search online for the installation process)

It is recommended to place the main configuration file in: /etc/supervisord.conf vim /etc/supervisord.conf

[unix_http_server]
file=/var/run/supervisor.sock

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisord]
nodaemon=true

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock

[include]
files = /etc/supervisor/conf.d/*.conf

Then add the startup commands for php and nginx in /etc/supervisor/conf.d/

For example, add nginx, vim /etc/supervisor/conf.d/nginx_super.conf

[program:nginx]
command=nginx
  1. Then submit a new image, for example

docker commit -a "qclaogui" -m "bulabula" nginx-php:commit

  1. Write a new Dokcerfile

FROM nginx-php:commit

MAINTAINER xxx@xxx.com

EXPOSE 80 443

ENTRYPOINT ["/usr/bin/supervisord","-c","/etc/supervisord.conf"]
  1. Rebuild an image

docker build -t nginx-php:v1 .

  1. Run the container based on the newly built image

docker run --name test-nginx-php -p 8081:80 -d nginx-php:v1注意这里用的是-dParameters

Depending on your situation, the general solution is as follows, you can refer to it

仅有的幸福

You need to be in Dokcerfile 里写上 CMD ["nginx", "-g", "daemon off;"]

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template