John Davidson

How to start the php-fpm server in docker?


FROM php:7.4-fpm

RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libmcrypt-dev \
gcc \
make \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd

RUN set -xe; \
apt-get update -yqq && \
pecl channel-update && \
apt-get install -yqq \
apt-utils \
libzip-dev zip unzip && \
docker-php-ext-configure zip; \
docker-php-ext-install zip && \
php -m | grep -q 'zip'

RUN docker-php-ext-install pdo_mysql
RUN apt-get install -y nano
RUN apt-get install -y build-essential cron
RUN apt-get install -y cron
RUN apt-get install -y procps
RUN apt-get install -y net-tools

RUN apt-get update && apt-get install libmagickwand-dev -y --no-install-recommends \
&& pecl install imagick-3.5.1 \
&& docker-php-ext-enable imagick

RUN apt-get install -y ghostscript

COPY --from=composer /usr/bin/composer /usr/bin/composer
ENV PATH $PATH:/composer/vendor/bin

WORKDIR /var/www

RUN apt-get install -y git

COPY ./src /var/www
COPY ./php/php.ini /usr/local/etc/php/php.ini
COPY ./php/policy.xml /etc/ImageMagick-6/policy.xml

RUN chmod -R 777 /var/www/storage
RUN chmod -R 777 /var/www/bootstrap

I have docker file like this.

It can create the container but, there is no server in it.

in container, it accept only ip6

tcp6       0      0 :::9000                 :::*                    LISTEN

I want to access fpm-cgi server by curl localhost 9000

Where should I set?

My Answer:
To start the php-fpm server in a Docker container, you can follow these steps:

1. Create a Dockerfile with the following content:

FROM php:7.4-fpm

RUN apt-get update

2. Build the Docker image using the following command:

docker build -t my-php-fpm .

3. Run the Docker container with the following command:

docker run -d my-php-fpm

This will start the php-fpm server in the Docker container and you can access it by connecting to the container or exposing the necessary ports.

Rate this post

3 of 5 based on 5961 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us