How does a Docker container always run in the background using PHP-FPM?

Source: Internet
Author: User
On the basis of the official centos started a container, installed in the PHP-FPM. now I want this container to run in the background, and another container (such as the NGINX server container) is connected to its PHP-FPM service. The following is my startup parameter: {code ...} {code ...} the container does not seem to be... on the basis of the official centos started a container, installed in the PHP-FPM.
Now I want this container to run in the background, and another container (such as the NGINX server container) will connect to its PHP-FPM Service
The following are my startup parameters:

# Test/php is the image name docker-d -- name php-fpm test/php/usr/sbin/php-fpm
docker -d --name php-fpm test/php /usr/sbin/php-fpm -D #daemonize

In the container, it seems that php-fpm cannot be started through the service.

[root@5233bbc57e72 /]# systemctl start php-fpmFailed to get D-Bus connection: No connection to service manager.

So install a supervisor.

#/etc/supervisord.conf[supervisord]logfile=/var/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)logfile_backups=10          ; (num of main logfile rotation backups;default 10)loglevel=info               ; (log level;default info; others: debug,warn,trace)pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)nodaemon=true               ; (start in foreground if true;default false)minfds=1024                 ; (min. avail startup file descriptors;default 1024)minprocs=200                ; (min. avail process descriptors;default 200);umask=022                  ; (process file creation umask;default 022);user=chrism                 ; (default is current user, required if root);identifier=supervisor       ; (supervisord identifier, default is 'supervisor');directory=/tmp              ; (default is not to cd during start);nocleanup=true [include]files = supervisord.d//*.ini[program:php-fpm]command=/bin/bash -c "/usr/sbin/php-fpm -D"

Start

docker run -d test/php /usr/bin/supervisord

If the container can be maintained in the background, but php-fpm is not started!
The configuration of php-fpm is default.

Reply content:

On the basis of the official centos started a container, installed in the PHP-FPM.
Now I want this container to run in the background, and another container (such as the NGINX server container) will connect to its PHP-FPM Service
The following are my startup parameters:

# Test/php is the image name docker-d -- name php-fpm test/php/usr/sbin/php-fpm
docker -d --name php-fpm test/php /usr/sbin/php-fpm -D #daemonize

In the container, it seems that php-fpm cannot be started through the service.

[root@5233bbc57e72 /]# systemctl start php-fpmFailed to get D-Bus connection: No connection to service manager.

So install a supervisor.

#/etc/supervisord.conf[supervisord]logfile=/var/log/supervisor/supervisord.log  ; (main log file;default $CWD/supervisord.log)logfile_maxbytes=50MB       ; (max main logfile bytes b4 rotation;default 50MB)logfile_backups=10          ; (num of main logfile rotation backups;default 10)loglevel=info               ; (log level;default info; others: debug,warn,trace)pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)nodaemon=true               ; (start in foreground if true;default false)minfds=1024                 ; (min. avail startup file descriptors;default 1024)minprocs=200                ; (min. avail process descriptors;default 200);umask=022                  ; (process file creation umask;default 022);user=chrism                 ; (default is current user, required if root);identifier=supervisor       ; (supervisord identifier, default is 'supervisor');directory=/tmp              ; (default is not to cd during start);nocleanup=true [include]files = supervisord.d//*.ini[program:php-fpm]command=/bin/bash -c "/usr/sbin/php-fpm -D"

Start

docker run -d test/php /usr/bin/supervisord

If the container can be maintained in the background, but php-fpm is not started!
The configuration of php-fpm is default.

  1. Directly use the official PHP Docker image.
    Https://registry.hub.docker.com/_/php/
  2. View how to use the dockerfile of the official Docker image.
    Https://github.com/docker-library/php/blob/32887c1de338d0ad582393b5f1d...
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.