如何在 docker 容器内重新启动 php-fpm?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37806188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to restart php-fpm inside a docker container?
提问by Eugene Sue
I'm using docker and my container is build over php:5.6-fpm image from php official repo. Is it somehow possible to restart/reload php-fpm from inside a container?
我正在使用 docker,我的容器是通过php 官方 repo 中的php:5.6-fpm 图像构建的。是否有可能从容器内重新启动/重新加载 php-fpm?
回答by Enrico Stahn
php-fpm
is a process manager which supports the USER2 signal, which is used to reload the config file.
php-fpm
是一个支持 USER2 信号的进程管理器,用于重新加载配置文件。
From inside the container:
从容器内部:
kill -USR2 1
Outside:
外部:
docker exec -it <mycontainer> kill -USR2 1
Complete example:
完整示例:
docker run -d --name test123 php:7.1-fpm-alpine
docker exec -it test123 ps aux
docker exec -it test123 kill -USR2 1
docker exec -it test123 ps aux
回答by user2652810
This works for me:
这对我有用:
If the command fpm restart fails run this inside the Docker container -> www#:
如果命令 fpm restart 失败,请在 Docker 容器中运行此命令 -> www#:
root@...:/var/www# **ps -ef|grep fpm**
www-data 160 1 0 10:02 ? 00:00:00 php-fpm: pool www
www-data 161 1 0 10:02 ? 00:00:00 php-fpm: pool www
root 1111 170 0 10:04 pts/0 00:00:00 grep --color=auto fpm
root@...:/var/www# **kill -USR2 170**
root@...:/home/user/Docker# **docker-compose stop**
Stopping docker_nginx_1 ... done
Stopping docker_oracle_1 ... done
root@...:/home/user/Docker# **docker-compose up -d**
Starting docker_oracle_1 ... done
Starting docker_nginx_1 ... done
root@...:/home/user/Docker# **docker-compose exec oracle bash**
root@...:/var/www# **/etc/init.d/php7.2-fpm restart**
* Restarting PHP 7.2 FastCGI Process Manager php-fpm7.2 **[ OK ]**
回答by too
You don't have to go inside the container
你不必进入容器内
on your host
ps -ef|grep fpm // find master pid
kill -USR2 <master_pid>
在你的主机上
ps -ef|grep fpm // find master pid
kill -USR2 <master_pid>
回答by Fractalf
You can also just restart the container..
您也可以重新启动容器..
sudo docker <container> restart