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?
You can use supervisord to manage
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
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
Then submit a new image, for example
docker commit -a "qclaogui" -m "bulabula" nginx-php:commit
Write a new Dokcerfile
Rebuild an image
docker build -t nginx-php:v1 .
Run the container based on the newly built image
docker run --name test-nginx-php -p 8081:80 -d nginx-php:v1
注意这里用的是-d
ParametersDepending 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;"]