Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart php-fpm inside a docker container?

Tags:

php

docker

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?

like image 737
Eugene Sue Avatar asked Jun 14 '16 07:06

Eugene Sue


People also ask

How do you restart PHP-FPM?

Log into WHM as root. Search “PHP-FPM” and select PHP-FPM service for Apache. Select Yes to restart the PHP-FPM service.

Can I reboot in docker?

Docker provides restart policies to control whether your containers start automatically when they exit, or when Docker restarts. Restart policies ensure that linked containers are started in the correct order. Docker recommends that you use restart policies, and avoid using process managers to start containers.


2 Answers

php-fpm is a process manager which supports the USER2 signal, which is used to reload the config file.

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
like image 67
Enrico Stahn Avatar answered Oct 12 '22 14:10

Enrico Stahn


You don't have to go inside the container

on your host ps -ef|grep fpm // find master pid kill -USR2 <master_pid>

like image 45
too Avatar answered Oct 12 '22 12:10

too