How to self-start the php-fpm service when building a LNMP environment with docker?

in order to facilitate development, we plan to create a LNMP environment based on docker, which makes it much more convenient to change computers or unify the team"s development environment.

choreographed a docker-compose.yaml file with nginx, php-fpm, mysql, redis and other services. All of them have been done except php-fpm

.

tell me about the process:

  • first of all, pull"s official php image php:7.x-fpm . Create images and containers, and have no problems connecting to other containers
  • .
  • but the PHP extension (extension) supported by this image is too few, and many commonly used ones do not (such as the gd library)
  • is installed by setting RUN docker-php-ext-install gd in Dockerfile, indicating that libpng library
  • is missing.
  • enter the container and install it with yum install-y libpng , prompting yum is an unknown command
  • installs yum through rpm xxx , prompting that rpm is an unknown command.

then change the way of thinking and plan to create your own php-fpm image based on the centos image, so:

  • pull official centos 7.x image, enter the container to download the php source code package, and compile and install it smoothly
  • start the container and find that the php-fpm service
  • cannot be opened automatically.
  • in docker-compose , command and entrypoint define commands (not at the same time):
    / path/to/sbin/php-fpm-y / path/to/etc/php-fpm.conf . When the container starts, the service fails to start, and the prompt message is equivalent to entering: php-fpm-h , all related parameters
  • .

I feel that this problem is because php-fpm is in the sbin directory and can only be run by a superuser, but executing command or entrypoint when the container is started is not a superuser, so it fails
, which causes me to enter php container to manually open the service every time I start container orchestration

.

I really don"t know what to do. I hope all of you can give me some hints:
1. How do I make the centos container automatically open the php-fpm service when it starts?
2. Or instead of using this idea, we can use other solutions

.

Thank you very much, thank you ~

Feb.26,2021

you can docker logs container name look at the container log


as soon as I finished this post, I saw another post:
https://codeshelper.com/q/10.

.

found that the original official php:7.x-fpm image is based on ubantu, and of course there is no yum
, so we still adopt the idea we just started, using apt-get to install the relevant packages, and OK to solve the problem of PHP extension

.

execute
RUN / usr/local/php/sbin/php-fpm

in Dockerfile
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bce2c0-30bc4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bce2c0-30bc4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?